chore(ops): centralize OpsRequest condition reason literals and fix message typos#10195
Conversation
|
Auto Cherry-pick Instructions |
|
QA review pass carried over from #10194. This PR uses the accepted branch prefix ( Original QA review trail: #10194 (comment) |
Review trail (carried over from closed PR #10194)This PR is the same commit (
Local validation evidence
The only outstanding gate on #10194 was the branch-name pre-check; that is resolved by this re-opened PR. |
|
@CLAassistant recheck |
|
recheckcla |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10195 +/- ##
==========================================
+ Coverage 52.27% 52.73% +0.45%
==========================================
Files 531 531
Lines 60705 61062 +357
==========================================
+ Hits 31736 32198 +462
+ Misses 25748 25646 -102
+ Partials 3221 3218 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@CLAassistant recheck |
|
/recheck-cla |
|
Recheck CLA triggered. |
…essage typos No behavior change. The Reason string values emitted at runtime are preserved exactly; this commit only replaces the inline string literals in apis/operations/v1alpha1/opsrequest_conditions.go with named constants in the same file, and corrects three message typos in pkg/operations. Why - Console, integration tests, and an upcoming reason catalog/registry match on the Reason string value rather than the Go identifier. A silent rename would break consumers without a compile-time signal. - The same Reason values are referenced in multiple files, so a single authoritative declaration prevents drift. Reason constants centralized - ReasonValidateOpsRequestPassed = "ValidateOpsRequestPassed" - ReasonOpsRequestProcessedSuccessfully = "OpsRequestProcessedSuccessfully" - ReasonRestartStarted = "RestartStarted" - ReasonStartToRebuildInstances = "StartToRebuildInstances" - ReasonSwitchoverStarted = "SwitchoverStarted" - ReasonVerticalScalingStarted = "VerticalScalingStarted" - ReasonHorizontalScalingStarted = "HorizontalScalingStarted" - ReasonVolumeExpansionStarted = "VolumeExpansionStarted" - ReasonExposeStarted = "ExposeStarted" - ReasonVersionUpgradeStarted = "VersionUpgradeStarted" - ReasonStopStarted = "StopStarted" - ReasonStartCluster = "StartCluster" - ReasonReconfigureStarted = "ReconfigureStarted" - ReasonReconfigureFailed = "ReconfigureFailed" - ReasonBackupStarted = "BackupStarted" - ReasonRestoreStarted = "RestoreStarted" Typo fixes (user-visible failure messages only; English grammar) - pkg/operations/rebuild_instance.go:112 "is availabled" -> "is available" - pkg/operations/rebuild_instance.go:491 "has been modifeied" -> "has been modified" - pkg/operations/custom.go:305 "cannot found the component" -> "cannot find the component" Tests - New TestReasonConstantsStringDrift pins the literal value of every Reason constant; a future rename or string change will fail the test. - New TestNewConditionReasonsMatchConstants verifies each NewXxxCondition constructor sets Condition.Reason to the centralized constant. - Existing TestNewAllCondition and TestSetStatusCondition continue to pass. - pkg/operations and controllers/operations Ginkgo suites run green with envtest assets. Prepared with Ava assistance.
80381b0 to
ac84e22
Compare
|
/approved |
|
/cherry-pick release-1.1 |
|
🤖 says: Error cherry-picking. |
|
🤖 says: |
Summary
No behavior change. Centralizes the inline Reason string literals in
apis/operations/v1alpha1/opsrequest_conditions.gointo named constants in the same file, and corrects three user-visible message typos inpkg/operations.This is the first slice of the OpsRequest status reason model work; it intentionally adds nothing else (no new vocabulary, no catalog/registry, no phase changes, no evidence backfill). Subsequent slices will introduce the structured anchor reasons and the catalog on top of these constants.
What changed
Reason constants centralized
The
NewXxxConditionconstructors previously setCondition.Reasonto inline string literals (e.g."VolumeExpansionStarted"). The literal values are unchanged; they are now declared once in the existing constants block and referenced from each constructor. 16 new exported constants:ReasonValidateOpsRequestPassedValidateOpsRequestPassedReasonOpsRequestProcessedSuccessfullyOpsRequestProcessedSuccessfullyReasonRestartStartedRestartStartedReasonStartToRebuildInstancesStartToRebuildInstancesReasonSwitchoverStartedSwitchoverStartedReasonVerticalScalingStartedVerticalScalingStartedReasonHorizontalScalingStartedHorizontalScalingStartedReasonVolumeExpansionStartedVolumeExpansionStartedReasonExposeStartedExposeStartedReasonVersionUpgradeStartedVersionUpgradeStartedReasonStopStartedStopStartedReasonStartClusterStartClusterReasonReconfigureStartedReconfigureStartedReasonReconfigureFailedReconfigureFailedReasonBackupStartedBackupStartedReasonRestoreStartedRestoreStartedTypo fixes (English grammar in user-visible failure messages)
pkg/operations/rebuild_instance.go:112instance "%s" is availabled, can not rebuild itinstance "%s" is available, can not rebuild itpkg/operations/rebuild_instance.go:491the replicas of the component "%s" has been modifeied by another operationthe replicas of the component "%s" has been modified by another operationpkg/operations/custom.go:305cannot found the component "%s" in cluster "%s"cannot find the component "%s" in cluster "%s"These messages are surfaced via
intctrlutil.NewFatalErrorand end up inOpsRequest.statusand reconciler logs, so they are externally visible.New tests
TestReasonConstantsStringDriftpins the literal value of every Reason constant. A silent rename or string change fails the test, defending consumers that match on the Reason string value rather than the Go identifier.TestNewConditionReasonsMatchConstantsverifies that eachNewXxxConditionconstructor returns a Condition whoseReasonequals the centralized constant. Defends against an accidental in-place edit that re-introduces an inline string literal.Test plan
go test ./apis/operations/v1alpha1/...(4 tests, including the two new ones) — passesgo test ./pkg/operations/util/...— passes (8.8s)go test ./pkg/operations/...(full Ginkgo suite, envtest 1.26.1) — passes (28.8s)go test ./controllers/operations/...— passes (17.9s)go vet ./apis/operations/v1alpha1/... ./pkg/operations/...— cleanmodifeied,availabled,cannot found) returns zero matches after this change.Out of scope (subsequent slices)
Failed; tracked separately).backup.go,restore.go,rebuild_instance_inplace.go,ops_manager.go).make verifylint analyzer enforcing registered reasons and required evidence.