-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Lambda: Fix behaviour for alias update and delete operations #11878
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
Conversation
All contributors have signed the CLA ✍️ ✅ |
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.
Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.
I have read the CLA Document and I hereby sign the CLA |
recheck |
2a959fb
to
74670a0
Compare
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.
This is a great first iteration, thank you! I just have some minor comments and questions. Also, it would be nice to add a quick docstring for every new test which describes the scenario being tested, one line is sufficient. (We try to do that for new tests, although as you see, it is not consistent across the codebase).
@@ -1818,8 +1816,12 @@ def update_alias( | |||
function = self._get_function( | |||
function_name=function_name, region=region, account_id=account_id | |||
) | |||
fn_arn = api_utils.unqualified_lambda_arn(function_name, account_id, region) |
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.
There is a utility qualified_lambda_arn
as well, where you can specify the alias name as qualifier directly, to avoid manually appending :{name}
. Also, we only need to calculate this value in the if
block, could you move it there?
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.
Totally agree, I focused to much on making it work and didn't place it in the right place. Done.
"tests/aws/services/lambda_/test_lambda_api.py::TestLambdaUrl::test_function_url_config_deletion_without_qualifier": { | ||
"last_validated_date": "2024-11-19T17:37:22+00:00" | ||
}, |
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.
It seems you renamed the test at some point, which leads to these leftovers. Can you (just manually) delete that entry, to keep the validation file tidier?
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.
Removed it.
self, create_lambda_function_aws, lambda_su_role, snapshot, aws_client | ||
): | ||
function_name = f"alias-fn-{short_uid()}" | ||
snapshot.add_transformer(SortingTransformer("Aliases", lambda x: x["Name"])) |
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.
Why is this transformer necessary here?
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.
copy-pasting 🍝 from a test that worked, it's not needed actually. Thanks for the catch.
self, create_lambda_function_aws, lambda_su_role, snapshot, aws_client | ||
): | ||
function_name = f"alias-fn-{short_uid()}" | ||
snapshot.add_transformer(SortingTransformer("Aliases", lambda x: x["Name"])) |
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.
Same question: Why is this necessary for this test? (as well in the third test)
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.
copy-pasting 🍝 from a test that worked, it's not needed actually. Thanks for the catch.
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.
Looks good to me now, thank you for addressing my comments! I will not merge it now on purpose (even though it is ready), we will do that together in our next meeting.
Thank you for this contribution!
Motivation
As reported in #11832:
update_alias
anddelete_alias
, a generic ValueError was thrown which was not in sync with the AWS behavior.delete_function_url_config
with no qualifier, the AWS behavior on the alias fnxs deletion was not clear.It seems:
delete_alias
for non-existing alias (but a 204 🤷🏼).ResourceNotFoundException( f"Alias not found: {fn_arn}:{name}", Type="User")
when updating an alias that doesn't exist (not a ValueError).delete_function_url_config
, AWS doesn't delete the function url configs of all aliases, when not specifying the Qualifier.Changes
delete_alias
when alias doesn't exist.update_alias
when alias doesn't exist.test_non_existent_alias_deletion
andtest_non_existent_alias_update
test_url_config_deletion_without_qualifier
that shows the behaviour on the alias fnxs deletion (doesn't delete the function url configs of all aliases when qualifier not specified)Let me know if I missed something, or if I messed up 🙏🏼