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: inopportune scaling events would lose some status fields #3060

Merged
merged 1 commit into from
Oct 4, 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
18 changes: 14 additions & 4 deletions rollout/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,11 @@
if err != nil {
return err
}
newStatus := c.rollout.Status.DeepCopy()

// NOTE: it is possible for newRS to be nil (e.g. when template and replicas changed at same time)
if c.rollout.Spec.Strategy.BlueGreen != nil {
previewSvc, activeSvc, err := c.getPreviewAndActiveServices()
_, activeSvc, err := c.getPreviewAndActiveServices()
if err != nil {
return nil
}
Expand All @@ -286,7 +287,15 @@
// so we can abort this resync
return err
}
return c.syncRolloutStatusBlueGreen(previewSvc, activeSvc)
activeRS, _ := replicasetutil.GetReplicaSetByTemplateHash(c.allRSs, newStatus.BlueGreen.ActiveSelector)
if activeRS != nil {
newStatus.HPAReplicas = activeRS.Status.Replicas
newStatus.AvailableReplicas = activeRS.Status.AvailableReplicas
} else {
// when we do not have an active replicaset, accounting is done on the default rollout selector
newStatus.HPAReplicas = replicasetutil.GetActualReplicaCountForReplicaSets(c.allRSs)
newStatus.AvailableReplicas = replicasetutil.GetAvailableReplicaCountForReplicaSets(c.allRSs)
}

Check warning on line 298 in rollout/sync.go

View check run for this annotation

Codecov / codecov/patch

rollout/sync.go#L295-L298

Added lines #L295 - L298 were not covered by tests
}
// The controller wants to use the rolloutCanary method to reconcile the rollout if the rollout is not paused.
// If there are no scaling events, the rollout should only sync its status
Expand All @@ -296,9 +305,10 @@
// so we can abort this resync
return err
}
return c.syncRolloutStatusCanary()
newStatus.AvailableReplicas = replicasetutil.GetAvailableReplicaCountForReplicaSets(c.allRSs)
newStatus.HPAReplicas = replicasetutil.GetActualReplicaCountForReplicaSets(c.allRSs)
}
return fmt.Errorf("no rollout strategy provided")
return c.persistRolloutStatus(newStatus)
}

// isScalingEvent checks whether the provided rollout has been updated with a scaling event
Expand Down
Loading