-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adds support to delete old versions when successful deployment #7414
base: develop
Are you sure you want to change the base?
Conversation
f414471
to
26d1e47
Compare
Hi, Thanks for bringing up this PR. The code looks good to me so Ill run the approval workflow to get the testing process started, but can you also create an integration tests testing the happy path from beginning to end? |
Can you also run |
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.
Thanks for opening this PR, left some comments. Additionally, we might want to consider adding this to the sam deploy
command. This might need some more thought though if this makes sense to you and the team.
version = self._lambda_client.publish_version(FunctionName=function_physical_id).get("Version") | ||
self._local_sha = str_checksum(str(version), hashlib.sha256()) | ||
LOG.debug("%sCreated new function version: %s", self.log_prefix, version) | ||
if version: | ||
self._lambda_client.update_alias( | ||
FunctionName=function_physical_id, Name=self._alias_name, FunctionVersion=version | ||
) | ||
if self._delete_old_alias and current_alias_version: | ||
function_name_w_version = "{}:{}".format(function_physical_id, current_alias_version) | ||
self._lambda_client.delete_function(FunctionName=function_name_w_version) |
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.
Will it ever be possible for this to be my_function:$LATEST
? Just wanted to ask what happens if the Lambda alias resolved to the latest version of the function, and if deleting my_function:$LATEST
just deletes the function.
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.
No, because there is no current alias. It only deletes old alias if there is an existing alias
current_alias_version
is the lambda.get_alias
operation. Does $LATEST
qualify as an alias?
Hi @driverpt, just wanted to check in about the state of this PR and if you had the capacity to work on it or if there was anything you needed to move forward |
Hello. I can work on it. But I'm waiting on the CF Spec to be discussed |
I've chatted with some team members, and the |
Hey @driverpt looking at the discussion here, I saw that recommendation is to use Thanks! |
Hi @driverpt, following up to check if you were planning to make the above requested changes and had any questions the team could help with. |
Hello. Haven't yet had the time to implement this. I'll probably take a look at it this weekend |
0826cfa
to
fb51370
Compare
a850205
to
f05e3c1
Compare
f05e3c1
to
0698b03
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.
Thanks for your contribution, left a comment about one method response where you wrapped it up with str
method.
return str( | ||
self._lambda_client.get_alias( | ||
FunctionName=self.get_physical_id(self._function_identifier), Name=self._alias_name | ||
).get("FunctionVersion") | ||
) |
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.
Wrapping .get
method response with str
will cause None
value to be returned as "None"
(string), so the IF statement above will not work as intended.
return str( | |
self._lambda_client.get_alias( | |
FunctionName=self.get_physical_id(self._function_identifier), Name=self._alias_name | |
).get("FunctionVersion") | |
) | |
return self._lambda_client.get_alias( | |
FunctionName=self.get_physical_id(self._function_identifier), Name=self._alias_name | |
).get("FunctionVersion") |
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.
Hi @driverpt is there any chance you can address this comment? Thanks!
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.
Hi @driverpt, thank you for your contribution.
We would like to circle back to the suggestion. Feel free to mention any of us here after you get a change to implement the change.
Which issue(s) does this change fix?
#7398
Why is this change necessary?
Because there's a limit on how many versions a Lambda has.
How does it address the issue?
Automatically deletes old version. Very useful when on SnapStart
What side effects does this change have?
None, it's disabled by default
Mandatory Checklist
PRs will only be reviewed after checklist is complete
make pr
passesmake update-reproducible-reqs
if dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.