@@ -174,32 +174,39 @@ def create_function(self, code_package: Benchmark, func_name: str) -> "KnativeFu
174
174
raise RuntimeError ("Failed to access func binary" )
175
175
176
176
177
- def cached_function (self , function : Function ):
178
- # Implementation of retrieving cached function details for Knative
179
- pass
180
-
181
177
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
+ )
185
186
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
193
200
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 )
198
209
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
203
210
204
211
def create_trigger (self , function : Function , trigger_type : Trigger .TriggerType ) -> Trigger :
205
212
if trigger_type == Trigger .TriggerType .LIBRARY :
@@ -227,9 +234,6 @@ def create_trigger(self, function: Function, trigger_type: Trigger.TriggerType)
227
234
else :
228
235
raise RuntimeError ("Not supported!" )
229
236
230
- def shutdown (self ) -> None :
231
- # Clean up any resources or connections
232
- pass
233
237
234
238
@staticmethod
235
239
def name () -> str :
0 commit comments