← Back to Pull requests

fix: apply maxSurge during rolling updates of Fleets with Allocated GameServers #4795

Closed
unknown closed this pull request without merging on Nov 02, 2026 19:07 UTC
View on GitHub
unknown unknown commented on Oct 21, 2026 06:41 UTC
Author

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 maxSurge number of GameServers to the Fleet". On a Fleet where most GameServers are Allocated this does not happen: rollingUpdateActive caps the active GameServerSet at fleet.Spec.Replicas - sumAllocated (the Allocated GameServers of the inactive GameServerSets) before maxSurge is considered, so maxSurge has no effect.

This PR applies maxSurge as documented, behind a new RollingUpdateSurge alpha feature gate. When enabled:

  • The active GameServerSet may grow until all GameServerSets together hold fleet.Spec.Replicas + maxSurge GameServers, and never beyond fleet.Spec.Replicas on its own, as in a Kubernetes Deployment. Each inactive GameServerSet counts as max(Spec.Replicas, Status.Replicas), so GameServers it is still creating, or cannot remove because they are Allocated, use the same budget.

  • The current target is kept, up to fleet.Spec.Replicas minus the Allocated and Reserved GameServers of the inactive GameServerSets so that a Fleet scale down still applies, but only the surge budget raises it.

  • The same rule applies after the inactive GameServerSets have been scaled to zero. Falling back to 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.

  • While the active GameServerSet is still creating GameServers (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.

  • The Ready based scale down of the inactive GameServerSets and Recreate are 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 by rollingUpdateActive when the gate is enabled. With the gate, applyDeploymentStrategy also takes the rolling update path after the inactive GameServerSets reach zero, so both cases use the same calculation.

  • RollingUpdateSurge added as an alpha gate in features.go, defaultfeaturegates.yaml, ALPHA_FEATURE_GATES, the e2e runner config in cloudbuild.yaml, test/upgrade/versionMap.yaml (Dev) and feature-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>, or Closes (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:

  • TestControllerRollingUpdateDeploymentSurge and TestControllerApplyDeploymentStrategySurge run 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.

  • TestControllerRollingUpdateSurgeInactiveTargetZero runs 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.

  • I have not run the e2e tests. With the gate enabled in e2e, TestFleetRollingUpdate should stay within its bound: the total stays within the larger of fleet.Spec.Replicas + maxSurge and today's fleet.Spec.Replicas plus the unallocated inactive GameServers, which is not above the bound without the gate.

  • The feature-stages.md row links to the rolling update guide. I can point it to the issue instead once it has a number.
  • Diff: 611 lines (+458 / -153) across 7 files Reviewer: markmandel Review duration: 18025m
    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
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%