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

fix: modified UniformAcrossAzUpdateStrategy update strategy to be as expected #395

Merged
merged 1 commit into from
Oct 24, 2023
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
27 changes: 20 additions & 7 deletions controllers/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,16 +461,29 @@
}

var AZtargets = make([]*autoscaling.Instance, 0)
AZs := awsprovider.GetScalingAZs(targets)
if len(AZs) == 0 {
return AZtargets
}

// split targets into groups based on their AZ
targetsByAZ := map[string][]*autoscaling.Instance{}
for _, target := range targets {
AZ := aws.StringValue(target.AvailabilityZone)
if strings.EqualFold(AZ, AZs[0]) {
AZtargets = append(AZtargets, target)
az := aws.StringValue(target.AvailabilityZone)
targetsByAZ[az] = append(targetsByAZ[az], target)

Check warning on line 469 in controllers/upgrade.go

View check run for this annotation

Codecov / codecov/patch

controllers/upgrade.go#L468-L469

Added lines #L468 - L469 were not covered by tests
}

// round-robin across the AZs with targets uniformly first and then best effort with remaining
for {
if len(AZtargets) == len(targets) {
break
}

for az := range targetsByAZ {

Check warning on line 478 in controllers/upgrade.go

View check run for this annotation

Codecov / codecov/patch

controllers/upgrade.go#L477-L478

Added lines #L477 - L478 were not covered by tests
targetsByAZGroupSize := len(targetsByAZ[az])
if targetsByAZGroupSize > 0 {
AZtargets = append(AZtargets, targetsByAZ[az][targetsByAZGroupSize-1]) // append last target
targetsByAZ[az] = targetsByAZ[az][:targetsByAZGroupSize-1] // pop last target
}
}
}

if unavailableInt > len(AZtargets) {
unavailableInt = len(AZtargets)
}
Expand Down