keikoproj / upgrade-manager

Reliable, extensible rolling-upgrades of Autoscaling groups in Kubernetes
Apache License 2.0
140 stars 45 forks source link

uniformAcrossAzUpdate doesn't work as expected #349

Closed ZihanJiang96 closed 10 months ago

ZihanJiang96 commented 1 year ago

Is this a BUG REPORT or FEATURE REQUEST?:

BUG REPORT

What happened:

uniformAcrossAzUpdate strategy doesn't pick nodes uniformly across AZs.

What you expected to happen:

uniformAcrossAzUpdate should pick same number of nodes or same percentage of nodes from each AZ for update

How to reproduce it (as minimally and precisely as possible):

    } else if r.RollingUpgrade.UpdateStrategyType() == v1alpha1.UniformAcrossAzUpdateStrategy {
        for _, instance := range scalingGroup.Instances {
            if r.IsInstanceDrifted(instance) && !common.ContainsEqualFold(awsprovider.GetInstanceIDs(targets), aws.StringValue(instance.InstanceId)) {
                targets = append(targets, instance)
            }
        }

        var AZtargets = make([]*autoscaling.Instance, 0)
        AZs := awsprovider.GetScalingAZs(targets)
        if len(AZs) == 0 {
            return AZtargets
        }
        for _, target := range targets {
            AZ := aws.StringValue(target.AvailabilityZone)
            if strings.EqualFold(AZ, AZs[0]) {
                AZtargets = append(AZtargets, target)
            }
        }
        if unavailableInt > len(AZtargets) {
            unavailableInt = len(AZtargets)
        }
        return AZtargets[:unavailableInt]

the code always picks the nodes from the same AZ AZs[0] as target.