chore(ops): centralize OpsRequest condition reason literals and fix message typos#10194
Closed
weicao wants to merge 1 commit into
Closed
chore(ops): centralize OpsRequest condition reason literals and fix message typos#10194weicao wants to merge 1 commit into
weicao wants to merge 1 commit into
Conversation
…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.
Collaborator
|
Auto Cherry-pick Instructions |
|
Ava seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Collaborator
|
This branch name is not following the standards: feature/|bugfix/|release/|hotfix/|support/|releasing/|dependabot/ |
Contributor
Author
|
QA review pass for Slice A. Checked scope against OPS-S1 v1 boundary:
Local spot validation:
Only remaining blocker I see is the GitHub branch-name gate ( |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.