fix(autoscaling): settle completed refresh work before standby (#7333)

* fix(autoscaling): settle completed refresh work before standby

Record already settled replacement progress before standby changes member lifecycle. Reuse the owning completion helper after request validation under the existing group lock. Preserve pending replacements and unrelated group/region refreshes.

Signed-off-by: Andre Kurait <akurait@amazon.com>

* fix(autoscaling): preserve refreshes on empty standby requests

Settle completed refresh work only when standby will move a member. Reuse the group resolved under the existing lock and retain invalid-lifecycle rejection before refresh mutation.

Signed-off-by: Andre Kurait <akurait@amazon.com>

---------

Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-11-02 11:57:39 -04:00
1 parent bb5e692b87
commit 6a390496eb
2 files changed
+129 -1

No files matched your search

@@ -1057,6 +1057,9 @@ public class AutoScalingService implements PassedRoleLookup {
requireDesiredCapacityWithinBounds(asg, newDesired,
"To place into standby " + moving.size() + " instances");
}
if (!moving.isEmpty()) {
completeInstanceRefreshIfSettled(region, name, asg);
}
Instant now = Instant.now();
List<ScalingActivity> started = new ArrayList<>();
for (AsgInstance instance : moving) {
@@ -1257,7 +1260,10 @@ public class AutoScalingService implements PassedRoleLookup {
}
public void completeInstanceRefreshIfSettled(String region, String asgName) {
AutoScalingGroup asg = requireGroup(region, asgName);
completeInstanceRefreshIfSettled(region, asgName, requireGroup(region, asgName));
}
private void completeInstanceRefreshIfSettled(String region, String asgName, AutoScalingGroup asg) {
List<InstanceRefresh> activeRefreshes = instanceRefreshes.values().stream()
.filter(r -> region.equals(r.getRegion()))
.filter(r -> asgName.equals(r.getAutoScalingGroupName()))