Skip to content

fix: correct MaxSurge default assignment in SetDefaultDeploymentStrategy#332

Open
Xio-Shark wants to merge 1 commit intoopenkruise:masterfrom
Xio-Shark:fix/default-maxsurge-assignment
Open

fix: correct MaxSurge default assignment in SetDefaultDeploymentStrategy#332
Xio-Shark wants to merge 1 commit intoopenkruise:masterfrom
Xio-Shark:fix/default-maxsurge-assignment

Conversation

@Xio-Shark
Copy link
Copy Markdown

Summary

Fix a bug in SetDefaultDeploymentStrategy where the default value for MaxSurge was incorrectly assigned to MaxUnavailable instead of MaxSurge.

Before (buggy):

if strategy.RollingUpdate.MaxSurge == nil {
    maxSurge := intstr.FromString("25%")
    strategy.RollingUpdate.MaxUnavailable = &maxSurge  // wrong field
}

After (fixed):

if strategy.RollingUpdate.MaxSurge == nil {
    maxSurge := intstr.FromString("25%")
    strategy.RollingUpdate.MaxSurge = &maxSurge  // correct field
}

Impact

When MaxSurge was not explicitly set, the function would:

  1. Overwrite the previously set MaxUnavailable default with the maxSurge value
  2. Leave MaxSurge as nil
  3. This would cause the maxSurge==0 && maxUnavailable==0 fallback logic to incorrectly trigger

Test

  • go build ./... passes
  • go vet ./... passes

Made with Cursor

@kruise-bot kruise-bot requested review from FillZpp and veophi March 19, 2026 11:44
@kruise-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign furykerry for approval by writing /assign @furykerry in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot
Copy link
Copy Markdown

Welcome @Xio-Shark! It looks like this is your first PR to openkruise/rollouts 🎉

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.38%. Comparing base (8416512) to head (c2d9d8c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #332   +/-   ##
=======================================
  Coverage   51.38%   51.38%           
=======================================
  Files          66       66           
  Lines        8559     8559           
=======================================
  Hits         4398     4398           
  Misses       3575     3575           
  Partials      586      586           
Flag Coverage Δ
unittests 51.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The default value for MaxSurge was incorrectly assigned to
MaxUnavailable, causing MaxSurge to remain nil when not explicitly set.
This could lead to unexpected behavior in the rolling update strategy
where maxSurge==0 fallback logic would always trigger.

Made-with: Cursor

Signed-off-by: Teng Yanxi <151488904+Xio-Shark@users.noreply.github.com>
@Xio-Shark Xio-Shark force-pushed the fix/default-maxsurge-assignment branch from 2303413 to c2d9d8c Compare March 20, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants