Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Kumar <[email protected]>
  • Loading branch information
octonawish-akcodes committed Jul 2, 2024
1 parent ac9a9ab commit 7030290
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
3 changes: 2 additions & 1 deletion config/systems.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@
},
"nodejs": {
"base_images": {
"latest": "node:latest"
"20": "node:20",
"18": "node:18"
},
"images": [
"build",
Expand Down
54 changes: 29 additions & 25 deletions sebs/knative/knative.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,32 +174,39 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "KnativeFu
raise RuntimeError("Failed to access func binary")


def cached_function(self, function: Function):
# Implementation of retrieving cached function details for Knative
pass

def update_function(self, function: Function, code_package: Benchmark):
# Implementation of function update for Knative
# might involve updating the Knative service with a new Docker image
pass
self.logging.info(f"Updating an existing Knative function {function.name}.")
function = cast(KnativeFunction, function)
docker_image = self.system_config.benchmark_image_name(
self.name(),
code_package.benchmark,
code_package.language_name,
code_package.language_version,
)

def update_function_configuration(self, cached_function: Function, benchmark: Benchmark):
# Implementation of updating function configuration for Knative
pass

def default_function_name(self, code_package: Benchmark) -> str:
# Implementation of default function naming for Knative
return f"{code_package.name}-{code_package.language_name}-{code_package.language_version}"
try:
subprocess.run(
[
"func", "deploy",
"--path", code_package.code_location,
"--image", docker_image,
"--name", function.name,
],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
check=True,
)
function.config.docker_image = docker_image

def enforce_cold_start(self, functions: List[Function], code_package: Benchmark):
# Implementation of cold start enforcement for Knative
# I am assuiming this might involve deleting and redeploying the service to force a cold start
pass
except FileNotFoundError as e:
self.logging.error("Could not update Knative function - is the 'func' CLI installed and configured correctly?")
raise RuntimeError(e)
except subprocess.CalledProcessError as e:
self.logging.error(f"Unknown error when running function update: {e}!")
self.logging.error("Ensure the SeBS cache is cleared if there are issues with Knative!")
self.logging.error(f"Output: {e.stderr.decode('utf-8')}")
raise RuntimeError(e)

def download_metrics(self, function_name: str, start_time: int, end_time: int, requests: Dict[str, ExecutionResult], metrics: dict):
# Implementation of metric downloading for Knative
# Here I can review the knative inbuilt metric tool (flag) need to check
pass

def create_trigger(self, function: Function, trigger_type: Trigger.TriggerType) -> Trigger:
if trigger_type == Trigger.TriggerType.LIBRARY:
Expand Down Expand Up @@ -227,9 +234,6 @@ def create_trigger(self, function: Function, trigger_type: Trigger.TriggerType)
else:
raise RuntimeError("Not supported!")

def shutdown(self) -> None:
# Clean up any resources or connections
pass

@staticmethod
def name() -> str:
Expand Down

0 comments on commit 7030290

Please sign in to comment.