fix: apply maxSurge during rolling updates of Fleets with Allocated GameServers #4795
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 611 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.384
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4795"
general
weight: 0.35
markmandel
What type of PR is this?
/kind bug
What this PR does / Why we need it:
The Fleet update guide says a rolling update "adds the
maxSurgenumber ofGameServersto the Fleet". On a Fleet where most GameServers are Allocated this does not happen:rollingUpdateActivecaps the active GameServerSet atfleet.Spec.Replicas - sumAllocated(the Allocated GameServers of the inactive GameServerSets) beforemaxSurgeis considered, somaxSurgehas no effect.This PR applies
maxSurgeas documented, behind a newRollingUpdateSurgealpha feature gate. When enabled:fleet.Spec.Replicas + maxSurgeGameServers, and never beyondfleet.Spec.Replicason its own, as in a Kubernetes Deployment. Each inactive GameServerSet counts asmax(Spec.Replicas, Status.Replicas), so GameServers it is still creating, or cannot remove because they are Allocated, use the same budget.fleet.Spec.Replicasminus the Allocated and Reserved GameServers of the inactive GameServerSets so that a Fleet scale down still applies, but only the surge budget raises it.fleet.Spec.Replicas - blocked(the Allocated and Reserved GameServers of the inactive GameServerSets) there would delete the surged GameServers in one step, Ready ones included. Instead they are released as the Fleet replicas decrease or the Allocated GameServers drain.Spec.Replicas > Status.Replicas), its target is held. When it is above its target only because Allocated GameServers cannot be removed, the target is recalculated.Recreateare unchanged.For example, a Fleet of 1000 replicas with 870 Allocated and
maxSurge: 25%(250), with the Fleet replicas unchanged during the rollout:| | Inactive GameServerSet | Active GameServerSet | Total | Active without the gate |
|---|---|---|---|---|
| Rollout starts | 1000 (870 Allocated) | 250 | 1250 | 130 |
| Surged GameServers are Ready, inactive Ready ones removed, inactive scaled to 0 | 870 Allocated | 380 | 1250 | 130 |
| Allocated GameServers finish | 500 Allocated | 750 | 1250 | 500 |
| | 200 Allocated | 1000 | 1200 | 800 |
| Rollout completes | 0, deleted | 1000 | 1000 | 1000 |
Changes:
pkg/fleets/controller_rollingupdatesurge.go:rollingUpdateActiveSurge, used byrollingUpdateActivewhen the gate is enabled. With the gate,applyDeploymentStrategyalso takes the rolling update path after the inactive GameServerSets reach zero, so both cases use the same calculation.RollingUpdateSurgeadded as an alpha gate infeatures.go,defaultfeaturegates.yaml,ALPHA_FEATURE_GATES, the e2e runner config incloudbuild.yaml,test/upgrade/versionMap.yaml(Dev) andfeature-stages.md(published from 1.62.0).Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage:
Closes #<issue number>, orCloses (paste link of issue).Use "Work on #<issue number>" if you wish to reference the issue without closing it.
-->
Closes #4794
Did you use AI tools in preparing this PR?:
<!--
If you used AI tools in preparing your PR, you must disclose this in the description of your PR.
--->
Y - This PR was written in part with the assistance of generative AI. I reviewed the logic and the test cases.
Special notes for your reviewer:
TestControllerRollingUpdateDeploymentSurgeandTestControllerApplyDeploymentStrategySurgerun every case with the gate off and on, so the expected values show the behaviour change. The first includes the #800 scenario (Fleet scaled down during a rolling update), the second a Fleet scaled down after the inactive GameServerSets reached zero. Both cover an active GameServerSet held above its target by Allocated GameServers, and the first also a template change while the inactive GameServerSet is still scaling up.TestControllerRollingUpdateSurgeInactiveTargetZeroruns each case with the inactive GameServerSet target at its current size and at zero, and expects the same result, including Fleet scale down and Reserved GameServers.TestFleetRollingUpdateshould stay within its bound: the total stays within the larger offleet.Spec.Replicas + maxSurgeand today'sfleet.Spec.Replicasplus the unallocated inactive GameServers, which is not above the bound without the gate.feature-stages.mdrow links to the rolling update guide. I can point it to the issue instead once it has a number.