Skip to content

Conversation

@hongkailiu
Copy link
Member

We cannot keep them in pkg/cvo/status.go as it would create
dependency cycles.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 29, 2025
@openshift-ci-robot
Copy link
Contributor

@hongkailiu: This pull request explicitly references no jira issue.

In response to this:

We cannot keep them in pkg/cvo/status.go as it would create
dependency cycles.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 29, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hongkailiu

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2025
@hongkailiu hongkailiu force-pushed the ClusterStatusConditionType branch 5 times, most recently from 6150d88 to cd6c7c2 Compare October 29, 2025 23:15
@hongkailiu
Copy link
Member Author

With 36fb0ca, ClusterStatusConditionType is used only in a few places where they look very reasonable.

Screenshot 2025-10-29 at 19 39 28

We cannot keep them in `pkg/cvo/status.go` as it would create
dependency cycles.
@hongkailiu hongkailiu force-pushed the ClusterStatusConditionType branch from 36fb0ca to bfc7f69 Compare October 30, 2025 14:17
@JianLi-RH
Copy link
Contributor

/test e2e-extended-tests

@hongkailiu
Copy link
Member Author

/test e2e-hypershift

@jiajliu
Copy link

jiajliu commented Nov 4, 2025

e2e-extended-tests — Job failed.

No regression issue found in above test, the failed two cases in e2e-extended-tests are both automation issues.

@hongkailiu
Copy link
Member Author

#1252 (comment)

/verified by "the above tests"

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Nov 19, 2025
@openshift-ci-robot
Copy link
Contributor

@hongkailiu: This PR has been marked as verified by "the above tests".

In response to this:

#1252 (comment)

/verified by "the above tests"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@hongkailiu
Copy link
Member Author

/test e2e-hypershift

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

Walkthrough

Moved several ClusterStatusConditionType constants from pkg/cvo into pkg/internal and updated production code and tests to reference the new internal.* constants (e.g., ClusterStatusFailing → internal.ClusterStatusFailing, DesiredReleaseAccepted → internal.ReleaseAccepted). No other behavioral changes introduced.

Changes

Cohort / File(s) Summary
Internal constants
pkg/internal/constants.go
Added exported configv1.ClusterStatusConditionType constants: ClusterStatusFailing, ClusterVersionInvalid, ReleaseAccepted, ImplicitlyEnabledCapabilities, UpgradeableAdminAckRequired, UpgradeableDeletesInProgress, UpgradeableClusterOperators, UpgradeableClusterVersionOverrides, UpgradeableUpgradeInProgress.
Removed public/constants usage in core CVO
pkg/cvo/status.go, pkg/cvo/metrics.go, pkg/cvo/upgradeable.go
Removed previously exported condition constants from pkg/cvo and replaced usages with internal.* equivalents; added internal imports and adjusted lookups/updates accordingly.
Upgradeable preconditions / payload
pkg/payload/precondition/clusterversion/upgradeable.go
Replaced string-cast condition Type with internal.UpgradeableClusterVersionOverrides; added internal import.
Metrics tests & adjustments
pkg/cvo/metrics_test.go, pkg/cvo/metrics.go
Switched failing-condition lookups to use internal.ClusterStatusFailing; tests updated to import internal and simplified some string-literal cases.
CVO unit & scenario tests
pkg/cvo/status_test.go, pkg/cvo/cvo_test.go, pkg/cvo/cvo_scenarios_test.go, pkg/cvo/upgradeable_test.go
Added internal imports and updated test data/assertions to reference internal.* constants (e.g., internal.ClusterStatusFailing, internal.ReleaseAccepted, internal.ImplicitlyEnabledCapabilities).
Integration / start tests
pkg/start/start_integration_test.go
Imported internal and replaced uses of cvo.ClusterStatusFailing with internal.ClusterStatusFailing in condition lookups.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25–35 minutes

  • Heterogeneous but systematic replacements across many files; includes removal of exported constants (API surface change) requiring careful sweep.
  • Pay extra attention to:
    • Any remaining references to the removed pkg/cvo exported constants across the repo and external consumers.
    • Import correctness for pkg/internal and potential import-cycle risks.
    • Places where string literals were used vs. the new constants to ensure consistent types.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between cea8161 and d5212c0.

📒 Files selected for processing (2)
  • pkg/cvo/upgradeable.go (10 hunks)
  • pkg/internal/constants.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/cvo/upgradeable.go
  • pkg/internal/constants.go
🔇 Additional comments (3)
pkg/internal/constants.go (2)

3-7: LGTM: Import addition is appropriate.

The configv1 import is necessary for the ClusterStatusConditionType definitions.


37-73: LGTM: Well-documented constants with clear semantic meaning.

The constants are properly typed, comprehensively documented, and centralized to avoid dependency cycles as noted in the PR objectives.

pkg/cvo/upgradeable.go (1)

189-189: LGTM: Consistent refactoring to use centralized constants.

All condition type references have been correctly updated to use the internal package constants, improving maintainability and avoiding dependency cycles.

Also applies to: 241-241, 272-272, 298-298, 362-362, 386-386, 402-402, 423-423, 431-431, 533-533


Comment @coderabbitai help to get the list of available commands and usage tips.

@hongkailiu
Copy link
Member Author

/test e2e-extended-tests

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/cvo/status.go (1)

666-669: Bug in conflict retry path: wrong error variable checked

In applyClusterVersionStatus, the conflict retry checks the original err instead of the cErr from the follow-up Get:

existing, cErr := client.ClusterVersions().Get(ctx, required.Name, metav1.GetOptions{})
if err != nil {
    return nil, cErr
}

This will always take the branch (because err is the prior conflict) and can return (nil, nil) when cErr == nil, despite not having an updated object.

Recommend fixing to check cErr:

-       existing, cErr := client.ClusterVersions().Get(ctx, required.Name, metav1.GetOptions{})
-       if err != nil {
-           return nil, cErr
-       }
+       existing, cErr := client.ClusterVersions().Get(ctx, required.Name, metav1.GetOptions{})
+       if cErr != nil {
+           return nil, cErr
+       }

This issue is pre-existing but worth addressing while touching this area.

🧹 Nitpick comments (1)
pkg/cvo/cvo_scenarios_test.go (1)

32-35: Scenario tests consistently migrated to internal condition-type constants

The many expectations on ClusterVersion conditions now use internal.ImplicitlyEnabledCapabilities, internal.ClusterStatusFailing, and internal.DesiredReleaseAccepted, keeping tests in lockstep with the centralized definitions while preserving all behaviors; any remaining raw "Failing" string types are functionally equivalent and can be unified later if desired.

Also applies to: 188-3860

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 667bc63 and bfc7f69.

📒 Files selected for processing (11)
  • pkg/cvo/cvo_scenarios_test.go (31 hunks)
  • pkg/cvo/cvo_test.go (50 hunks)
  • pkg/cvo/metrics.go (1 hunks)
  • pkg/cvo/metrics_test.go (6 hunks)
  • pkg/cvo/status.go (7 hunks)
  • pkg/cvo/status_test.go (19 hunks)
  • pkg/cvo/upgradeable.go (9 hunks)
  • pkg/cvo/upgradeable_test.go (3 hunks)
  • pkg/internal/constants.go (2 hunks)
  • pkg/payload/precondition/clusterversion/upgradeable.go (2 hunks)
  • pkg/start/start_integration_test.go (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/cvo/cvo_scenarios_test.go
  • pkg/cvo/upgradeable_test.go
  • pkg/start/start_integration_test.go
  • pkg/cvo/status.go
  • pkg/cvo/metrics.go
  • pkg/internal/constants.go
  • pkg/cvo/upgradeable.go
  • pkg/cvo/cvo_test.go
  • pkg/cvo/metrics_test.go
  • pkg/payload/precondition/clusterversion/upgradeable.go
  • pkg/cvo/status_test.go
🔇 Additional comments (10)
pkg/internal/constants.go (1)

3-7: Centralized ClusterStatusConditionType constants look correct and well-documented

The new internal constants keep the existing string values and types, and the added GoDoc makes these user-facing conditions clearer while avoiding dependency cycles.

Also applies to: 37-70

pkg/cvo/metrics_test.go (1)

26-27: Metrics tests correctly migrated to internal condition constants

Using internal.ClusterStatusFailing for failing conditions and plain string literals for custom/unknown types keeps the tests aligned with the new central constants while preserving behavior and label expectations.

Also applies to: 334-336, 484-485, 522-523, 721-742

pkg/start/start_integration_test.go (1)

34-35: Integration tests now consistently use internal.ClusterStatusFailing

Both failing-condition guards in waitForUpdateAvailable correctly reference internal.ClusterStatusFailing, matching the new centralized definition without changing behavior.

Also applies to: 607-613, 681-683

pkg/cvo/metrics.go (1)

520-534: Failure metric lookup correctly switched to internal.ClusterStatusFailing

The failing-condition lookup in Collect now uses the centralized internal.ClusterStatusFailing constant, preserving behavior while reducing duplication.

pkg/cvo/upgradeable_test.go (1)

12-13: Upgradeable tests correctly reference internal.DesiredReleaseAccepted

Switching the condition Type fields to internal.DesiredReleaseAccepted keeps the tests aligned with the new shared constant while leaving the throttle-period logic unchanged.

Also applies to: 27-49

pkg/payload/precondition/clusterversion/upgradeable.go (1)

16-18: Overrides precondition now uses centralized UpgradeableClusterVersionOverrides

Using internal.UpgradeableClusterVersionOverrides in ClusterVersionOverridesCondition centralizes the condition type without altering the upgrade-blocking logic.

Also applies to: 34-41

pkg/cvo/status_test.go (1)

6-7: Tests correctly track internal.ClusterStatusFailing move

Importing pkg/internal and swapping all failing-condition Type fields and lookups to internal.ClusterStatusFailing keeps the test behavior identical while centralizing the constant definition. No issues spotted with the updated expectations.

Also applies to: 116-117, 157-158, 256-259, 268-271, 287-297, 318-329, 351-360, 383-394, 426-460, 486-497, 523-533, 563-567, 590-599, 621-632, 654-665, 688-699, 746-747

pkg/cvo/cvo_test.go (1)

47-50: Internal condition-type constants are used consistently in tests

The switch from public constants/literals to internal.ClusterStatusFailing, internal.ImplicitlyEnabledCapabilities, and internal.ClusterVersionInvalid in the various sync/available-updates/invalid-clusterversion tests is consistent and preserves the asserted status shapes. This tightly couples tests to the condition type strings in one place, which is appropriate given the refactor.

Also applies to: 225-228, 257-262, 300-306, 378-381, 450-456, 538-541, 668-671, 712-716, 755-759, 813-819, 868-875, 928-933, 981-987, 1081-1084, 1125-1131, 1210-1214, 1279-1284, 1371-1376, 1450-1456, 1526-1534, 1612-1617, 1698-1702, 1796-1799, 1871-1877, 1979-1987, 2067-2073, 2170-2176, 2210-2216, 2483-2486, 2546-2552, 2613-2619, 2675-2681, 2715-2719

pkg/cvo/status.go (1)

25-29: Condition-type constants successfully centralized in pkg/internal

Using internal.ClusterVersionInvalid, internal.ClusterStatusFailing, internal.ImplicitlyEnabledCapabilities, and internal.DesiredReleaseAccepted in status calculation and sync-failure paths keeps the logic identical while avoiding direct constant definitions in cvo. Given the tests now also reference these internal constants, the refactor looks safe and maintainable.

Also applies to: 248-257, 300-321, 447-481, 483-511, 486-511, 628-632

pkg/cvo/upgradeable.go (1)

30-35: Upgradeable condition and throttle constants correctly moved to pkg/internal

The upgradeable checks now emit condition Types via internal.UpgradeableClusterOperators, internal.UpgradeableClusterVersionOverrides, internal.UpgradeableDeletesInProgress, and internal.UpgradeableAdminAckRequired, and throttlePeriod keys off internal.DesiredReleaseAccepted. Together with using internal.AdminGatesConfigMap / internal.AdminAcksConfigMap, this centralizes condition and ConfigMap names without altering the surrounding logic.

Also applies to: 188-193, 241-243, 298-300, 315-320, 362-367, 386-436, 533-539

@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Nov 19, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
pkg/cvo/cvo_scenarios_test.go (1)

31-3653: Test expectations consistently aligned to internal condition-type constants

Across these scenarios, switching Type fields to internal.ImplicitlyEnabledCapabilities, internal.ClusterStatusFailing, and internal.ReleaseAccepted keeps the condition strings stable while routing everything through the new shared constants. This improves maintainability and avoids divergence between tests and production code, with no observable behavior change.

You might later consider pulling remaining hard-coded condition-type strings (like "Failing"/"Available" where applicable) into the same internal constants for full consistency, but that is not required for this PR.

pkg/cvo/upgradeable.go (1)

25-31: Upgradeable checks correctly refactored to use internal condition-type constants

The upgradeable checks and throttle logic now consistently use internal.Upgradeable* and internal.ReleaseAccepted, centralizing condition-type definitions without altering behavior. This reduces the risk of drift and dependency cycles between packages.

If you continue consolidating condition-type strings, you could also move "UpgradeableUpgradeInProgress" into pkg/internal for symmetry with the other upgradeable condition types in a future change.

Also applies to: 187-232, 239-263, 296-309, 311-438, 533-539

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between bfc7f69 and 76f0dd4.

📒 Files selected for processing (5)
  • pkg/cvo/cvo_scenarios_test.go (31 hunks)
  • pkg/cvo/status.go (7 hunks)
  • pkg/cvo/upgradeable.go (9 hunks)
  • pkg/cvo/upgradeable_test.go (3 hunks)
  • pkg/internal/constants.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/internal/constants.go
  • pkg/cvo/status.go
  • pkg/cvo/cvo_scenarios_test.go
  • pkg/cvo/upgradeable.go
  • pkg/cvo/upgradeable_test.go
🔇 Additional comments (3)
pkg/internal/constants.go (1)

37-69: Centralizing condition-type constants looks correct

The new configv1.ClusterStatusConditionType constants are well-documented, string values match their names, and they provide a single source of truth for the user-facing condition types without changing behavior.

pkg/cvo/upgradeable_test.go (1)

12-49: Tests correctly switched to internal ReleaseAccepted constant

Using internal.ReleaseAccepted in these test conditions aligns them with the new centralized constant definitions without altering the expected behavior.

pkg/cvo/status.go (1)

25-28: Status condition wiring cleanly migrated to internal constants

Using internal.ClusterVersionInvalid, internal.ClusterStatusFailing, internal.ImplicitlyEnabledCapabilities, and internal.ReleaseAccepted here keeps condition-type strings centralized while preserving existing behavior for validation, failing, capabilities, and release-acceptance conditions.

Also applies to: 248-257, 300-320, 447-480, 483-511, 627-632

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/cvo/status.go (1)

248-257: Consistent use of internal condition types looks correct

Switching the various condition types to internal.* (ClusterVersionInvalid, ClusterStatusFailing, ImplicitlyEnabledCapabilities, ReleaseAccepted) plus extracting setReleaseAcceptedCondition is a straightforward refactor: control flow, status transitions, and messages are unchanged and only the constant source moves.

As long as the new internal constants preserve the existing string values, this should be a pure, non‑breaking change and improves maintainability by centralizing condition type definitions.

If you want extra guardrails, consider a small unit test in pkg/internal (or a doc comment) asserting these condition strings remain stable over time, since they are surfaced via status and may be consumed externally.

Also applies to: 262-263, 300-320, 466-481, 483-511, 628-632

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 76f0dd4 and cea8161.

📒 Files selected for processing (1)
  • pkg/cvo/status.go (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/cvo/status.go
🔇 Additional comments (1)
pkg/cvo/status.go (1)

25-29: Internal constants import improves dependency structure

Importing pkg/internal here to source shared ClusterStatusConditionType constants centralizes their definition and avoids local duplication/cycles. No issues with this change.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants