-
Notifications
You must be signed in to change notification settings - Fork 3
Fix: Race between layer and Lambda update (#5927) #7436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
achave11-ucsc
merged 47 commits into
develop
from
issues/dsotirho-ucsc/5927-layer-and-lambda-race-2
Nov 8, 2025
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
46aaf7a
Refactor patch_refs() to use PEP 695 type parameter
dsotirho-ucsc 5fcd339
Extract method
dsotirho-ucsc 137a349
Implement Lambda function versions (#5927)
dsotirho-ucsc d405604
Delete inactive function versions at deploy time (#5927)
dsotirho-ucsc 0a3f8ab
Tweak comment (#5927)
hannes-ucsc 07acc2b
Refactor method
hannes-ucsc 6919104
Remove unnecessary pair of parentheses for generator expression
hannes-ucsc a37591f
[1/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc b3bceb1
[2/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 73941d9
[3/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc c556c6a
[4/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 6278d5b
[5/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc c1366c7
[6/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 5ad26b1
[7/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc d744e8c
[8/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 53a69c4
[9/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc e47801e
[10/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 137c0d7
[11/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 68f3632
[12/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 1f0c69b
[13/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 32489a4
[14/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc c29b9ba
[15/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc fdbe63a
[16/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc bdd6d98
[17/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc eb5862e
[18/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc f0f30e8
[19/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 3ec3b0f
[20/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 5630d0e
[21/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 5f030d8
[22/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 4d6d3f7
[23/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 63a1876
[24/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 405761e
[25/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 9e8a3a3
[26/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 1923574
[27/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc e84f9a7
[28/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 7415ab4
[29/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 0a0b957
[30/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc cca74c9
[31/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc df53068
[32/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc a5f6fea
[33/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 52de395
[34/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 46c197c
[35/40] Substitute "lambda" with either "app" or "function"
hannes-ucsc 0c5bc8f
Don't use f-strings for log statements
hannes-ucsc 39074bb
Invert `if` condition
hannes-ucsc 86a476d
Convert reassignment to assertion
hannes-ucsc 711d158
Add docstrings
hannes-ucsc df2b150
Reorder statements
hannes-ucsc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """ | ||
| Delete all versions of a Lambda function prior to the specified one. | ||
| """ | ||
| import argparse | ||
| import logging | ||
| import sys | ||
|
|
||
| from azul import ( | ||
| R, | ||
| config, | ||
| ) | ||
| from azul.args import ( | ||
| AzulArgumentHelpFormatter, | ||
| ) | ||
| from azul.lambdas import ( | ||
| LambdaFunctions, | ||
| ) | ||
| from azul.logging import ( | ||
| configure_script_logging, | ||
| ) | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def main(argv: list[str]): | ||
| assert config.terraform_component == '', R( | ||
| 'This script cannot be run with a Terraform component selected', | ||
| config.terraform_component) | ||
| parser = argparse.ArgumentParser(description=__doc__, | ||
| formatter_class=AzulArgumentHelpFormatter) | ||
| parser.add_argument('--function-name', '-f', | ||
| required=True, | ||
| help='The name of the Lambda function.') | ||
| parser.add_argument('--function-version', '-v', | ||
| type=int, | ||
| required=True, | ||
| help='The Lambda function version to keep. Must be an ' | ||
| 'integer.') | ||
| args = parser.parse_args(argv) | ||
| log.info('Deleting function %r versions older than %r', | ||
| args.function_name, args.function_version) | ||
| functions = LambdaFunctions() | ||
| functions.delete_older_versions(args.function_name, args.function_version) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| configure_script_logging(log) | ||
| main(sys.argv[1:]) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,14 +42,14 @@ def main(): | |
| sources=set()) | ||
| } | ||
|
|
||
| lambda_name = Path.cwd().name | ||
| assert lambda_name in config.lambda_names(), lambda_name | ||
| app_name = Path.cwd().name | ||
| assert app_name in config.app_names(), app_name | ||
|
|
||
| # To create a normalized OpenAPI document, we patch any | ||
| # deployment-specific variables that affect the document. | ||
| with ( | ||
| patch_config('catalogs', catalogs), | ||
| patch_config(f'{lambda_name}_function_name', f'azul-{lambda_name}-dev'), | ||
| patch_config(f'{app_name}_function_name', f'azul-{app_name}-dev'), | ||
| patch_config('enable_log_forwarding', False), | ||
| patch_config('enable_replicas', True), | ||
| patch_config('monitoring_email', '[email protected]') | ||
|
|
@@ -58,10 +58,10 @@ def main(): | |
| with patch.object(target=AzulChaliceApp, | ||
| attribute='base_url', | ||
| new=lambda_endpoint): | ||
| app_module = load_app_module(lambda_name) | ||
| app_module = load_app_module(app_name) | ||
| assert app_module.app.base_url == lambda_endpoint | ||
| app_spec = app_module.app.spec() | ||
| doc_path = Path(config.project_root) / 'lambdas' / lambda_name / 'openapi.json' | ||
| doc_path = Path(config.project_root) / 'lambdas' / app_name / 'openapi.json' | ||
| with write_file_atomically(doc_path) as file: | ||
| json.dump(app_spec, file, indent=4) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New scripts and modules should be covered by mypy.