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
Fix architecture update for Lambda function #10263
Conversation
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.
🙌 were just talking about this yesterday, great job
if len(architectures) != 1: | ||
raise ValidationException( | ||
f"1 validation error detected: Value '[{', '.join(architectures)}]' at 'architectures' failed to " | ||
f"satisfy constraint: Member must have length less than or equal to 1", | ||
) |
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.
if len(architectures) != 1: | |
raise ValidationException( | |
f"1 validation error detected: Value '[{', '.join(architectures)}]' at 'architectures' failed to " | |
f"satisfy constraint: Member must have length less than or equal to 1", | |
) | |
if len(architectures) > 1: | |
raise ValidationException( | |
f"1 validation error detected: Value '[{', '.join(architectures)}]' at 'architectures' failed to " | |
f"satisfy constraint: Member must have length less than or equal to 1", | |
) |
Shouldn't be an empty architectures list be fine according to the error message? (would also affect the architectores[0]
below since then it won't be safe anymore.
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.
If that's not the case (bc AWS treats it as null and thus returns the error msg below), please add a comment 👍
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.
Added a comment:
# An empty list of architectures is also forbidden. Further exceptions are tested here for create_function:
# tests.aws.services.lambda_.test_lambda_api.TestLambdaFunction.test_create_lambda_exceptions
Limitation: only works on ARM hosts that support x86 emulation. | ||
def test_mixed_architecture(self, create_lambda_function, aws_client, snapshot): | ||
"""Test emulation of a lambda function changing architectures. | ||
Limitation: only works on hosts that support both ARM and AMD64 architectures. |
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.
Interesting limitation. Think we should introduce a marker for this
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.
Agree that adding marker is better than the plain skip. Maybe adding an arm marker:
only_on_amd64 = pytest.mark.only_on_amd64
only_on_arm64 = pytest.mark.only_on_arm64
This special test would then have both markers.
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's just visually a bit tricky to distinguish:
amd64
arm64
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.
True but fortunately markers are mostly for automation and filtering purposes, so I'd say that's ok 👍
Motivation
UpdateFunctionCode does not support updating the Architectures (e.g., x64 => ARM).
This issue has been reported and reproduced by @cabeaulac based on customer input.
Changes
test_mixed_architecture
to useUpdateFunctionCode
UpdateFunctionCode
Testing
Our CI pipeline currently does not support cross-architecture emulation. Therefore, this change can only be tested locally on a machine with cross-architecture support (e.g., ARM MacBook):
tests.aws.services.lambda_.test_lambda.TestLambdaBehavior.test_mixed_architecture
tests.aws.services.lambda_.test_lambda.TestLambdaBehavior.test_mixed_architecture