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
🐛 AWSMachinePool: Prune old Launch Template versions #2525
🐛 AWSMachinePool: Prune old Launch Template versions #2525
Conversation
0c89d6b
to
8a94a14
Compare
Remove one old version before creating a new version.
8a94a14
to
a1bba0a
Compare
Once this is approved, I'd like to backport to |
sgtm |
/priority important/soon |
@randomvariable: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@@ -455,6 +455,11 @@ func (r *AWSMachinePoolReconciler) reconcileLaunchTemplate(machinePoolScope *sco | |||
// userdata, OR we've discovered a new AMI ID. | |||
if needsUpdate || tagsChanged || *imageID != *launchTemplate.AMI.ID || launchTemplateUserDataHash != bootstrapDataHash { | |||
machinePoolScope.Info("creating new version for launch template", "existing", launchTemplate, "incoming", machinePoolScope.AWSMachinePool.Spec.AWSLaunchTemplate) | |||
// There is a limit to the number of Launch Template Versions. | |||
// We ensure that the number of versions does not grow without bound by following a simple rule: For each version we create, we delete one old version. | |||
if err := ec2svc.PruneLaunchTemplateVersions(machinePoolScope.AWSMachinePool.Status.LaunchTemplateID); err != nil { |
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.
Is it better to create one before pruning? In case creation fails we don't want to delete the previous one.
We create a new one, it is tagged as latest, so the previous can be deleted.
CreateLaunchTemplateVersion
returns the version created, how about directly trying to delete the previous version? Assuming the numbering is strictly increasing.
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.
Is it better to create one before pruning?
If we create one before removing one, then we may end up never removing any. Whether or not we return an error when we fail to remove one, we'll create more than we'll remove, and therefore eventually reach the limit.
In case creation fails we don't want to delete the previous one.
We create a new one, it is tagged as latest, so the previous can be deleted.
I took care to never remove the version that is currently "in use." Please see the PruneLaunchTemplateVersions
godoc, and let me know if anything is unclear. 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.
I've revised the comment at this line. I hope it's more clear now.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sedefsavas The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks for reviewing, @sedefsavas! |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Remove one old version before creating a new version.
Fixes #2368
Special notes for your reviewer:
I'm not sure what sort of unit test we want to see.
Checklist:
Release note: