diff --git a/sebs/aws/aws.py b/sebs/aws/aws.py index dd7077d18..34ab2e66f 100644 --- a/sebs/aws/aws.py +++ b/sebs/aws/aws.py @@ -617,6 +617,17 @@ def default_function_name( func_name = f"{func_name}-docker" return AWS.format_function_name(func_name) + def normalize_function_name(self, func_name: str) -> str: + """Apply the AWS name conversion done in create_function to user-provided names. + + Args: + func_name: Function name, possibly provided by the user + + Returns: + str: Function name as deployed and cached + """ + return AWS.format_function_name(func_name) + @staticmethod def format_function_name(func_name: str) -> str: """Format function name for AWS Lambda compatibility. diff --git a/sebs/faas/storage.py b/sebs/faas/storage.py index 6db96f3af..ca1ee3cf8 100644 --- a/sebs/faas/storage.py +++ b/sebs/faas/storage.py @@ -431,12 +431,12 @@ def get_bucket(self, bucket_type: Resources.StorageBucketType) -> str: Resources.StorageBucketType.DEPLOYMENT: "code deployment", } - name = self._cloud_resources.get_storage_bucket_name(bucket_type) + name = self.correct_name(self._cloud_resources.get_storage_bucket_name(bucket_type)) if not self.exists_bucket(name): self.logging.info(f"Initialize a new bucket for {description[bucket_type]}") bucket = self._create_bucket( - self.correct_name(name), + name, randomize_name=False, ) else: diff --git a/sebs/faas/system.py b/sebs/faas/system.py index 291e9ce75..da62893b3 100644 --- a/sebs/faas/system.py +++ b/sebs/faas/system.py @@ -418,6 +418,7 @@ def build_function(self, code_package: Benchmark, func_name: Optional[str] = Non if not func_name: func_name = self.default_function_name(code_package) + func_name = self.normalize_function_name(func_name) _, code_package_loc, system_variant, container_uri = code_package.build( self.package_code, self.container_client, self.finalize_container_build() ) @@ -471,6 +472,7 @@ def get_function(self, code_package: Benchmark, func_name: Optional[str] = None) # Generate function name if not provided if not func_name: func_name = self.default_function_name(code_package) + func_name = self.normalize_function_name(func_name) # Build the code package rebuilt, _, system_variant, container_uri = code_package.build( @@ -655,6 +657,21 @@ def default_function_name( """ pass + def normalize_function_name(self, func_name: str) -> str: + """ + Convert a function name to the form used by the platform. + + Platforms that rewrite function names on creation must override this, + so that cache lookups use the same name as the deployed function. + + Args: + func_name: Function name, possibly provided by the user + + Returns: + str: Function name as deployed and cached + """ + return func_name + @abstractmethod def enforce_cold_start(self, functions: List[Function], code_package: Benchmark): """