Skip to content
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

replace launchTemplate latest string with version number #296

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions controllers/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import (
var (
//DefaultWaitGroupTimeout is the timeout value for DrainGroup
DefaultWaitGroupTimeout = time.Second * 5

//LaunchTemplate latest string
LaunchTemplateVersionLatest = "$Latest"
)

// DrainManager holds the information to perform drain operation in parallel.
Expand Down Expand Up @@ -480,6 +483,11 @@ func (r *RollingUpgradeContext) IsInstanceDrifted(instance *autoscaling.Instance
templateVersion = aws.StringValue(scalingGroup.LaunchTemplate.Version)
)

// replace latest string with latest version number
if strings.EqualFold(templateVersion, LaunchTemplateVersionLatest) {
templateVersion = awsprovider.GetTemplateLatestVersion(r.Cloud.LaunchTemplates, launchTemplateName)
}

if !strings.EqualFold(launchTemplateName, instanceTemplateName) {
return true
} else if !strings.EqualFold(instanceTemplateVersion, templateVersion) {
Expand All @@ -498,6 +506,11 @@ func (r *RollingUpgradeContext) IsInstanceDrifted(instance *autoscaling.Instance
templateVersion = aws.StringValue(scalingGroup.LaunchTemplate.Version)
)

// replace latest string with latest version number
if strings.EqualFold(templateVersion, LaunchTemplateVersionLatest) {
templateVersion = awsprovider.GetTemplateLatestVersion(r.Cloud.LaunchTemplates, launchTemplateName)
}

if !strings.EqualFold(launchTemplateName, instanceTemplateName) {
return true
} else if !strings.EqualFold(instanceTemplateVersion, templateVersion) {
Expand Down