Skip to content

fix(operations): validate upgrade service version and fail fast on invalid format - #10470

Merged
wangyelei merged 2 commits into
mainfrom
bugfix/ops-upgrade-invalid-version-fail-fast
Jun 30, 2026
Merged

fix(operations): validate upgrade service version and fail fast on invalid format#10470
wangyelei merged 2 commits into
mainfrom
bugfix/ops-upgrade-invalid-version-fail-fast

Conversation

@wangyelei

Copy link
Copy Markdown
Contributor

Description

When OpsRequest upgrade is used with an invalid service version format (e.g., "17.5" instead of "17.5.0"), the OpsRequest gets stuck in Running status forever because:

  1. validateUpgrade() does not validate the ServiceVersion format, so invalid versions pass initial validation
  2. Later during ReconcileAction(), version.ParseSemantic() fails but returns a regular (non-fatal) error, causing infinite retry loops

Changes

apis/operations/v1alpha1/opsrequest_validation.go

  • Added ServiceVersion semver format validation in validateUpgrade() using version.ParseSemantic()
  • Empty strings and nil values are allowed (no version change or clear version)
  • Invalid formats (e.g., "17.5", "not-a-version") now fail during validation phase

pkg/operations/upgrade.go

  • Wrapped errors from GetCompDefByName() and UpdateCompDefinitionImages4ServiceVersion() as fatal errors via intctrlutil.NewFatalError()
  • Ensures that if a version resolution error does occur during reconciliation, the OpsRequest immediately transitions to Failed phase instead of retrying indefinitely

Tests

  • Added table-driven unit test TestValidateUpgradeServiceVersion (11 cases) for the validation function
  • Added Ginkgo integration test verifying upgrade with invalid version format transitions to OpsFailedPhase

Fix #10461

@wangyelei
wangyelei requested a review from a team as a code owner June 29, 2026 03:04
@apecloud-bot

Copy link
Copy Markdown
Collaborator

Auto Cherry-pick Instructions

Usage:
  - /nopick: Not auto cherry-pick when PR merged.
  - /pick: release-x.x [release-x.x]: Auto cherry-pick to the specified branch when PR merged.

Example:
  - /nopick
  - /pick release-1.1

CLA Recheck Instructions

Usage:
  - /recheck-cla: Trigger a re-check of CLA status for this pull request.
Example:
  - /recheck-cla

@github-actions github-actions Bot added the size/L Denotes a PR that changes 100-499 lines. label Jun 29, 2026
@wangyelei wangyelei added the pick-1.1 Auto cherry-pick to release-1.1 when PR merged label Jun 29, 2026
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.18%. Comparing base (d8cbb03) to head (619eba6).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10470      +/-   ##
==========================================
+ Coverage   62.10%   62.18%   +0.07%     
==========================================
  Files         533      533              
  Lines       63722    63727       +5     
==========================================
+ Hits        39577    39629      +52     
+ Misses      20547    20507      -40     
+ Partials     3598     3591       -7     
Flag Coverage Δ
unittests 62.18% <100.00%> (+0.07%) ⬆️

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

☔ 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.

@apecloud-bot apecloud-bot added the approved PR Approved Test label Jun 29, 2026
@wangyelei
wangyelei merged commit 84e21fd into main Jun 30, 2026
71 of 77 checks passed
@wangyelei
wangyelei deleted the bugfix/ops-upgrade-invalid-version-fail-fast branch June 30, 2026 02:28
@github-actions github-actions Bot added this to the Release 1.2.0 milestone Jun 30, 2026
@apecloud-bot

Copy link
Copy Markdown
Collaborator

/cherry-pick release-1.1

@apecloud-bot

Copy link
Copy Markdown
Collaborator

🤖 says: cherry pick action finished successfully 🎉!
See: https://github.com/apecloud/kubeblocks/actions/runs/28416170856

apecloud-bot pushed a commit that referenced this pull request Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved PR Approved Test pick-1.1 Auto cherry-pick to release-1.1 when PR merged size/L Denotes a PR that changes 100-499 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement]Use opsrequest for upgrading, while version formate is wrong, cannot stop the upgrading

3 participants