Skip to content

Commit 7030290

Browse files
fix
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent ac9a9ab commit 7030290

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

config/systems.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@
259259
},
260260
"nodejs": {
261261
"base_images": {
262-
"latest": "node:latest"
262+
"20": "node:20",
263+
"18": "node:18"
263264
},
264265
"images": [
265266
"build",

sebs/knative/knative.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -174,32 +174,39 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "KnativeFu
174174
raise RuntimeError("Failed to access func binary")
175175

176176

177-
def cached_function(self, function: Function):
178-
# Implementation of retrieving cached function details for Knative
179-
pass
180-
181177
def update_function(self, function: Function, code_package: Benchmark):
182-
# Implementation of function update for Knative
183-
# might involve updating the Knative service with a new Docker image
184-
pass
178+
self.logging.info(f"Updating an existing Knative function {function.name}.")
179+
function = cast(KnativeFunction, function)
180+
docker_image = self.system_config.benchmark_image_name(
181+
self.name(),
182+
code_package.benchmark,
183+
code_package.language_name,
184+
code_package.language_version,
185+
)
185186

186-
def update_function_configuration(self, cached_function: Function, benchmark: Benchmark):
187-
# Implementation of updating function configuration for Knative
188-
pass
189-
190-
def default_function_name(self, code_package: Benchmark) -> str:
191-
# Implementation of default function naming for Knative
192-
return f"{code_package.name}-{code_package.language_name}-{code_package.language_version}"
187+
try:
188+
subprocess.run(
189+
[
190+
"func", "deploy",
191+
"--path", code_package.code_location,
192+
"--image", docker_image,
193+
"--name", function.name,
194+
],
195+
stderr=subprocess.PIPE,
196+
stdout=subprocess.PIPE,
197+
check=True,
198+
)
199+
function.config.docker_image = docker_image
193200

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

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

204211
def create_trigger(self, function: Function, trigger_type: Trigger.TriggerType) -> Trigger:
205212
if trigger_type == Trigger.TriggerType.LIBRARY:
@@ -227,9 +234,6 @@ def create_trigger(self, function: Function, trigger_type: Trigger.TriggerType)
227234
else:
228235
raise RuntimeError("Not supported!")
229236

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

234238
@staticmethod
235239
def name() -> str:

0 commit comments

Comments
 (0)