Skip to content

fix(controller): honor scaleUpPreviewCheckPoint reset on blueGreen pod template change. Fixes #4728#4729

Open
abizer wants to merge 1 commit into
argoproj:masterfrom
abizer:fix-bluegreen-preview-status-check
Open

fix(controller): honor scaleUpPreviewCheckPoint reset on blueGreen pod template change. Fixes #4728#4729
abizer wants to merge 1 commit into
argoproj:masterfrom
abizer:fix-bluegreen-preview-status-check

Conversation

@abizer

@abizer abizer commented May 16, 2026

Copy link
Copy Markdown

What

Read prevValue from newStatus instead of c.rollout.Status in calculateScaleUpPreviewCheckPoint. When syncRolloutStatusBlueGreen calls resetRolloutStatus on pod template change, the reset mutates newStatus.BlueGreen.ScaleUpPreviewCheckPoint = false; reading from c.rollout.Status immediately afterwards picks up the pre-reset value, clobbering the reset.

- prevValue := c.rollout.Status.BlueGreen.ScaleUpPreviewCheckPoint
+ prevValue := newStatus.BlueGreen.ScaleUpPreviewCheckPoint

Why

Matches the function's documented behavior:

scaleUpPreviewCheckPoint... gets reset to false when the pod template changes, or the rollout fully promotes

Without this fix, a new revision started while the previous one was in the scale-up / autoPromotionSeconds window inherits scaleUpPreviewCheckPoint: true and skips prePromotionAnalysis entirely — the new preview RS scales straight to replicas (bypassing previewReplicaCount), no AnalysisRun is created, and cutover proceeds untested.

Full repro + root cause + live-cluster evidence in #4728.

Tests

  • Added unit regression test TestCalculateScaleUpPreviewCheckPointHonorsReset in rollout/bluegreen_test.go. Verified it fails on the unfixed code (Should be false) and passes with the fix.
  • Existing TestPreviewReplicaCountHandleScaleUpPreviewCheckPoint sub-tests (TrueAfterMeetingMinAvailable, FalseAfterActiveServiceSwitch, TrueWhenScalingUpPreview) continue to pass.
  • Full ./rollout/... package suite passes locally (make test equivalent).

Checklist

  • This is a bug fix.
  • PR title is conventional (fix(controller): ...), states what changed, and suffixes the related issue number (Fixes #4728).
  • Commits are DCO signed.
  • Unit tests written and passing.
  • All tests run locally and pass.
  • I have used LLM/AI/Agent tools for this PR but I am responsible for all code of this PR.
  • I understand what the code does and WHY/HOW it works in several scenarios.
  • This changes behavior for existing users of blueGreen + previewReplicaCount + prePromotionAnalysis: previously a back-to-back revision would skip the gate; now it correctly runs prePromotionAnalysis for the new revision. No API or config change.
  • My organization is added to USERS.md. (Out of scope for this bug fix — separate PR if needed.)

@github-actions

github-actions Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Published E2E Test Results

  4 files    4 suites   3h 50m 12s ⏱️
120 tests 107 ✅  7 💤 6 ❌
490 runs  454 ✅ 28 💤 8 ❌

For more details on these failures, see this check.

Results for commit d573618.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.05%. Comparing base (76a703a) to head (d573618).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4729      +/-   ##
==========================================
+ Coverage   84.99%   85.05%   +0.06%     
==========================================
  Files         164      164              
  Lines       18998    18998              
==========================================
+ Hits        16147    16159      +12     
+ Misses       1998     1992       -6     
+ Partials      853      847       -6     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Published Unit Test Results

2 474 tests   2 474 ✅  3m 21s ⏱️
  129 suites      0 💤
    1 files        0 ❌

Results for commit d573618.

♻️ This comment has been updated with latest results.

@abizer abizer force-pushed the fix-bluegreen-preview-status-check branch from b7f948b to 28c1d69 Compare May 23, 2026 14:12
@abizer abizer requested a review from a team as a code owner May 23, 2026 14:12
@abizer

abizer commented May 28, 2026

Copy link
Copy Markdown
Author

cc @argoproj/argo-rollouts-approvers

…d template change

When a new pod template is rolled out while the previous revision had
already completed prePromotionAnalysis (and thus set
status.blueGreen.scaleUpPreviewCheckPoint=true), the new revision
inherits that value and Argo Rollouts skips creating an AnalysisRun for
it entirely -- including the prePromotionAnalysis gate.

syncRolloutStatusBlueGreen calls resetRolloutStatus(&newStatus) on pod
template change, which clears newStatus.BlueGreen.ScaleUpPreviewCheckPoint.
The subsequent call to calculateScaleUpPreviewCheckPoint read prevValue
from c.rollout.Status (the pre-reset value) rather than the newStatus
parameter that was just reset, immediately clobbering the reset.

Read prevValue from newStatus so the reset applied earlier in the same
reconcile is honored, matching the documented behavior:

  // ... gets reset to false when the pod template changes, or the
  // rollout fully promotes (stableRS == newRS)

Add a regression test that fails on the old behavior and passes with
the fix.

Signed-off-by: Abizer Lokhandwala <abizer@abizer.me>
@abizer abizer force-pushed the fix-bluegreen-preview-status-check branch from 28c1d69 to d573618 Compare June 10, 2026 07:15
@sonarqubecloud

Copy link
Copy Markdown

@abizer

abizer commented Jun 10, 2026

Copy link
Copy Markdown
Author

@kostis-codefresh would you be able to take a look at this when you have a chance? it is a one line fix

@kostis-codefresh kostis-codefresh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that this unit test doesn't really cover the scenario that was described in #4728

It seems to me that we don't have any e2e tests that use previewReplicaCount anyway, so I want to be very cautious about the effects of this PR.

So can we add some e2e test(s) that showcase the bug and verify the actual fix in a more realistic way please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants