Skip to content

MGMT-19979: Propagate ClusterVersion upgrade status message #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

CrystalChun
Copy link
Collaborator

@CrystalChun CrystalChun commented Apr 8, 2025

Adds the upgrade message from the ClusterVersion in the workload cluster to the OACP's upgrade status so it's transparent to the user. Also adds a failure reason in case the upgrade fails.

Summary by CodeRabbit

  • New Features

    • Introduced a new constant for upgrade failure reasons, enhancing clarity on upgrade issues.
    • Improved upgrade status feedback with detailed messages for ongoing and failed upgrades.
  • Tests

    • Expanded test coverage validates the improved upgrade status handling and message consistency under various upgrade scenarios.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 8, 2025

@CrystalChun: This pull request references MGMT-19979 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

Adds the upgrade message from the ClusterVersion in the workload cluster to the OACP's upgrade status so it's transparent to the user. Also adds a failure reason in case the upgrade fails.

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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 8, 2025
Copy link

openshift-ci bot commented Apr 8, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 8, 2025
Copy link

openshift-ci bot commented Apr 8, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CrystalChun

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

Copy link

coderabbitai bot commented Apr 8, 2025

"""

Walkthrough

A new constant UpgradeFailedReason is added to specify upgrade failure reasons, and a dedicated function setUpgradeStatus is introduced to streamline upgrade status handling in the OpenshiftAssistedControlPlane controller. Additionally, the ClusterUpgrade interface and its implementation in OpenshiftUpgrader now include the GetUpgradeStatus method to retrieve upgrade messages. Corresponding updates have been made to tests and mock implementations to accurately simulate and validate various upgrade scenarios.

Changes

File(s) Change Summary
controlplane/api/v1alpha2/condition_consts.go Added constant UpgradeFailedReason = "UpgradeFailed" to denote an upgrade failure condition.
controlplane/internal/controller/openshiftassistedcontrolplane_controller.go
controlplane/internal/controller/openshiftassistedcontrolplane_controller_test.go
Created setUpgradeStatus to centralize upgrade status logic; updated tests to reflect various upgrade status messages returned by GetUpgradeStatus.
controlplane/internal/upgrade/upgrade.go
controlplane/internal/upgrade/upgrade_test.go
Introduced GetUpgradeStatus to the ClusterUpgrade interface and its implementation in OpenshiftUpgrader; enhanced tests with detailed cluster version conditions.
controlplane/internal/upgrade/mock_upgrade.go Added mock methods for GetUpgradeStatus and updated the mock recorder to simulate upgrade status calls.

Sequence Diagram(s)

sequenceDiagram
    participant C as Controller
    participant S as setUpgradeStatus
    participant U as Upgrader
    participant CM as ConditionManager

    C->>S: setUpgradeStatus(oacp, upgradeInProgress, msg)
    S->>U: GetUpgradeStatus(ctx)
    U-->>S: (upgradeMessage, error)
    alt Error encountered
        S->>C: Return error
    else
        S->>CM: conditions.MarkFalse(oacp, reason, upgradeMessage)
    end
Loading

Possibly related PRs

Suggested reviewers

  • rccrdpccl

Poem

I'm a rabbit coding in the wood,
Hopping through upgrades just as I should.
New constants and functions light my way,
With tests and mocks, I leap and play.
In our code garden, bugs take flight—
A joyful hop into a future bright!
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

level=warning msg="The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar."
level=error msg="[linters_context] exportloopref: This linter is fully inactivated: it will not produce any reports."
{"Issues":[],"Report":{"Warnings":[{"Text":"The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar."}],"Linters":[{"Name":"asasalint"},{"Name":"asciicheck"},{"Name":"bidichk"},{"Name":"bodyclose"},{"Name":"canonicalheader"},{"Name":"containedctx"},{"Name":"contextcheck"},{"Name":"copyloopvar"},{"Name":"cyclop"},{"Name":"decorder"},{"Name":"deadcode"},{"Name":"depguard"},{"Name":"dogsled"},{"Name":"dupl","Enabled":true},{"Name":"dupword"},{"Name":"durationcheck"},{"Name":"errcheck","Enabled":true,"EnabledByDefault":true},{"Name":"errchkjson"},{"Name":"errname"},{"Name":"errorlint"},{"Name":"execinquery"},{"Name":"exhaustive"},{"Name":"exhaustivestruct"},{"Name":"exhaustruct"},{"Name":"exportloopref","Enabled":true},{"Name":"exptostd"},{"Name":"forbidigo"},{"Name":"forcetypeassert"},{"Name":"fatcontext"},{"Name":"funlen"},{"Name":"gci"},{"Name":"ginkgolinter"},{"Name":"gocheckcompilerdirectives"},{"Name":"gochecknoglobals"},{"Name":"gochecknoinits"},{"Name":"gochecksumtype"},{"Name":"gocognit"},{"Name":"goconst","Enabled":true},{"Name":"gocritic"},{"Name":"gocyclo","Enabled":true},{"Name":"godot"},{"Name":"godox"},{"Name":"err113"},{"Name":"gofmt","Enabled":true},{"Name":"gofumpt"},{"Name":"goheader"},{"Name":"goimports","Enabled":true},{"Name":"golint"},{"Name":"mnd"},{"Name":"gomnd"},{"Name":"gomoddirectives"},{"Name":"gomodguard"},{"Name":"goprintffuncname"},{"Name":"gosec"},{"Name":"gosimple","Enabled":true,"EnabledByDefault":true},{"Name":"gosmopolitan"},{"Name":"govet","Enabled":true,"EnabledByDefault":true},{"Name":"grouper"},{"Name":"ifshort"},{"Name":"iface"},{"Name":"importas"},{"Name":"inamedparam"},{"Name":"ineffassign","Enabled":true,"EnabledByDefault":true},{"Name":"interfacebloat"},{"Name":"interfacer"},{"Name":"intrange"},{"Name":"ireturn"},{"Name":"lll","Enabled":true},{"Name":"loggercheck"},{"Name":"maintidx"},{"Name":"makezero"},{"Name":"maligned"},{"Name":"mirror"},{"Name":"misspell","Enabled":true},{"Name":"musttag"},{"Name":"nakedret","Enabled":true},{"Name":"nestif"},{"Name":"nilerr"},{"Name":"nilnesserr"},{"Name":"nilnil"},{"Name":"nlreturn"},{"Name":"noctx"},{"Name":"nonamedreturns"},{"Name":"nosnakecase"},{"Name":"nosprintfhostport"},{"Name":"paralleltest"},{"Name":"perfsprint"},{"Name":"prealloc","Enabled":true},{"Name":"predeclared"},{"Name":"promlinter"},{"Name":"protogetter"},{"Name":"reassign"},{"Name":"recvcheck"},{"Name":"revive"},{"Name":"rowserrcheck"},{"Name":"sloglint"},{"Name":"scopelint"},{"Name":"sqlclosecheck"},{"Name":"spancheck"},{"Name":"staticcheck","Enabled":true,"EnabledByDefault":true},{"Name":"structcheck"},{"Name":"stylecheck"},{"Name":"tagalign"},{"Name":"tagliatelle"},{"Name":"tenv"},{"Name":"testableexamples"},{"Name":"testifylint"},{"Name":"testpackage"},{"Name":"thelper"},{"Name":"tparallel"},{"Name":"typecheck","Enabled":true,"EnabledByDefault":true},{"Name":"unconvert","Enabled":true},{"Name":"unparam","Enabled":true},{"Name":"unused","Enabled":true,"EnabledByDefault":true},{"Name":"usestdlibvars"},{"Name":"usetesting"},{"Name":"varcheck"},{"Name":"varnamelen"},{"Name":"wastedassign"},{"Name":"whitespace"},{"Name":"wrapcheck"},{"Name":"wsl"},{"Name":"zerologlint"},{"Name":"nolintlint"}],"Error":"exportloopref: This linter is fully inactivated: it will not produce any reports."}}

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfd8d61 and 14994c6.

📒 Files selected for processing (6)
  • controlplane/api/v1alpha2/condition_consts.go (1 hunks)
  • controlplane/internal/controller/openshiftassistedcontrolplane_controller.go (3 hunks)
  • controlplane/internal/controller/openshiftassistedcontrolplane_controller_test.go (9 hunks)
  • controlplane/internal/upgrade/mock_upgrade.go (1 hunks)
  • controlplane/internal/upgrade/upgrade.go (2 hunks)
  • controlplane/internal/upgrade/upgrade_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • controlplane/api/v1alpha2/condition_consts.go
  • controlplane/internal/controller/openshiftassistedcontrolplane_controller.go
  • controlplane/internal/upgrade/upgrade_test.go
  • controlplane/internal/upgrade/mock_upgrade.go
  • controlplane/internal/controller/openshiftassistedcontrolplane_controller_test.go
  • controlplane/internal/upgrade/upgrade.go

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@openshift-ci openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 8, 2025
@rccrdpccl
Copy link
Contributor

approach seems reasonable, please make sure tests where we define CVO status (that we will expect to be reported on our CR) are added 🙏

@openshift-ci openshift-ci bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 10, 2025
@@ -506,8 +517,9 @@ var _ = Describe("Upgrade scenarios", func() {
Expect(k8sClient.Update(ctx, openshiftAssistedControlPlane)).To(Succeed())

mockUpgradeFactory.EXPECT().NewUpgrader(gomock.Any()).Return(mockUpgrader, nil)
mockUpgrader.EXPECT().IsUpgradeInProgress(gomock.Any()).Return(false, nil)
mockUpgrader.EXPECT().IsUpgradeInProgress(gomock.Any()).Return(true, nil) // should this be successfully starting upgrade?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @rccrdpccl should this test should handle upgrade with repository override return true that upgrade is in progress? I wasn't sure

Copy link
Contributor

Choose a reason for hiding this comment

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

According to the current behaviour, this should start an upgrade either way:

  • if UpgradeInProgress, but DesiredVersion is not updated, we should trigger an update
  • if Upgrade not in progress, and desiredVersion is not updated, we should still trigger an update.

I think the logic is fair, but would this work with CVO? Can we update the version if an upgrade is already running?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question, I can verify that!

@CrystalChun CrystalChun requested a review from rccrdpccl April 10, 2025 22:38
@CrystalChun CrystalChun marked this pull request as ready for review April 10, 2025 22:38
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 10, 2025
@CrystalChun
Copy link
Collaborator Author

Thanks @rccrdpccl 🙏 added checks to existing tests for correct statuses. Let me know if more tests are needed though!

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 10, 2025

@CrystalChun: This pull request references MGMT-19979 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

Adds the upgrade message from the ClusterVersion in the workload cluster to the OACP's upgrade status so it's transparent to the user. Also adds a failure reason in case the upgrade fails.

Summary by CodeRabbit

  • New Features

  • Enhanced upgrade status feedback now provides clear messaging for upgrade progress and failures, ensuring users receive precise information during the upgrade process.

  • Tests

  • Expanded test coverage validates the improved upgrade status handling and message consistency under various upgrade scenarios.

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.

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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aadb5f6 and b105693.

📒 Files selected for processing (6)
  • controlplane/api/v1alpha2/condition_consts.go (1 hunks)
  • controlplane/internal/controller/openshiftassistedcontrolplane_controller.go (3 hunks)
  • controlplane/internal/controller/openshiftassistedcontrolplane_controller_test.go (9 hunks)
  • controlplane/internal/upgrade/mock_upgrade.go (1 hunks)
  • controlplane/internal/upgrade/upgrade.go (2 hunks)
  • controlplane/internal/upgrade/upgrade_test.go (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
controlplane/internal/controller/openshiftassistedcontrolplane_controller_test.go (1)
controlplane/api/v1alpha2/condition_consts.go (2)
  • UpgradeCompletedCondition (13-13)
  • UpgradeFailedReason (40-40)
controlplane/internal/controller/openshiftassistedcontrolplane_controller.go (2)
controlplane/api/v1alpha2/openshiftassistedcontrolplane_types.go (1)
  • OpenshiftAssistedControlPlane (239-245)
controlplane/api/v1alpha2/condition_consts.go (3)
  • UpgradeInProgressReason (37-37)
  • UpgradeFailedReason (40-40)
  • UpgradeCompletedCondition (13-13)
🔇 Additional comments (15)
controlplane/api/v1alpha2/condition_consts.go (1)

39-40: Appropriate addition of the UpgradeFailedReason constant

The new constant for representing failed upgrades is well-defined and follows the existing pattern of other reason constants in the file. It has the correct comment format with severity information.

controlplane/internal/upgrade/upgrade_test.go (1)

179-185: Good test coverage for the new GetUpgradeStatus method

The test correctly verifies the expected behavior of the new method, ensuring it returns the upgrade progress message.

controlplane/internal/controller/openshiftassistedcontrolplane_controller.go (4)

289-290: Good addition of upgrade condition message tracking

The new variable appropriately captures the upgrade status message that will be propagated to users.


293-294: Good refactoring to use the centralized setUpgradeStatus function

Extracting this logic into a dedicated function improves code organization and maintainability.


314-317: Proper error handling for upgrade status retrieval

The code now correctly checks for errors when retrieving the upgrade status message, which improves robustness.


356-374: Well-structured centralized upgrade status function

The new setUpgradeStatus function effectively centralizes the logic for upgrade status handling, determining the appropriate reason and severity based on the upgrade state. It also properly includes the upgrade condition message in the status, which achieves the PR's objective of propagating ClusterVersion messages to users.

controlplane/internal/upgrade/mock_upgrade.go (1)

90-103: Appropriate mock implementation for the new GetUpgradeStatus method.

The mock implementation follows the standard pattern for GoMock, correctly defining both the method implementation and the mock recorder. This allows tests to verify the expected behavior of the GetUpgradeStatus method and ensures proper integration with the upgrade status reporting feature.

controlplane/internal/controller/openshiftassistedcontrolplane_controller_test.go (8)

84-84: LGTM: Good default behavior for mock setup.

Setting a default behavior for GetUpgradeStatus to return an empty string with no error is appropriate for most test scenarios, as it represents the case when no upgrade is in progress.


388-389: Appropriate mock expectation for the 'no upgrade in progress' scenario.

The mock is correctly set up to return an empty status message when no upgrade is in progress, maintaining consistency with the implementation in the controller.


408-409: Proper handling of upgrade status message in the in-progress scenario.

The test correctly verifies that the upgrade status message from the cluster is incorporated into the condition message. This allows users to see both the general upgrade progress and any specific details from the underlying ClusterVersion operator.

Also applies to: 423-423


430-431: Appropriate mock expectation for completed upgrade scenario.

When an upgrade is completed, the status message should be empty, which is correctly modeled in this test.


461-462: Correct implementation of failure status propagation.

The test properly verifies that when an upgrade fails, both the failure reason and the status message from the cluster are properly reflected in the condition. This ensures users get detailed information about the failure.

Also applies to: 484-485


493-494: Appropriate handling of version retrieval failures.

Even when there's an error getting the current version, the test correctly verifies that the upgrade status message is still propagated, ensuring users get as much information as possible about the issue.

Also applies to: 508-509


520-520: Clarify the expected upgrade state in this test.

There's uncertainty about whether this test should return that an upgrade is in progress or successfully starting. Consider documenting the reasoning for choosing "in progress" to clarify the intended behavior.

This appears to be a comment related to a previous review conversation with rccrdpccl. Based on the test context, the IsUpgradeInProgress returning true seems correct since the test is verifying the behavior when an upgrade is in progress with a repository override.


522-523: Proper status propagation with repository override.

The test correctly verifies that the upgrade status message is properly propagated when using a custom repository override, maintaining consistency with the other upgrade scenarios.

Also applies to: 543-543

Comment on lines +199 to +208
Conditions: []configv1.ClusterOperatorStatusCondition{
{
Message: "upgrade is in progress",
Status: configv1.ConditionTrue,
},
{
Message: "upgrade is not in progress",
Status: configv1.ConditionFalse,
},
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incomplete condition objects in test data

The added conditions are missing the Type field, which is normally required for ClusterOperatorStatusCondition objects. In the actual implementation, the condition Type is used to identify specific conditions.

 Conditions: []configv1.ClusterOperatorStatusCondition{
   {
+    Type:    configv1.OperatorProgressing,
     Message: "upgrade is in progress",
     Status:  configv1.ConditionTrue,
   },
   {
+    Type:    configv1.OperatorProgressing,
     Message: "upgrade is not in progress",
     Status:  configv1.ConditionFalse,
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Conditions: []configv1.ClusterOperatorStatusCondition{
{
Message: "upgrade is in progress",
Status: configv1.ConditionTrue,
},
{
Message: "upgrade is not in progress",
Status: configv1.ConditionFalse,
},
},
Conditions: []configv1.ClusterOperatorStatusCondition{
{
Type: configv1.OperatorProgressing,
Message: "upgrade is in progress",
Status: configv1.ConditionTrue,
},
{
Type: configv1.OperatorProgressing,
Message: "upgrade is not in progress",
Status: configv1.ConditionFalse,
},
},

Comment on lines 117 to 133
// Returns the cluster version's current upgrade condition message for the client's cluster.
// If any error occurs while performing this operation, it will be returned.
func (u *OpenshiftUpgrader) GetUpgradeStatus(ctx context.Context) (string, error) {
clusterVersion, err := u.getClusterVersion(ctx)
if err != nil {
return "", err
}
for _, condition := range clusterVersion.Status.Conditions {
if condition.Status == configv1.ConditionTrue {
return condition.Message, nil
}
}
return "", nil
}
Copy link

@coderabbitai coderabbitai bot Apr 10, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider filtering conditions by Type in GetUpgradeStatus

The current implementation returns the message from the first condition with status ConditionTrue without checking its Type. This might return messages from conditions unrelated to upgrades. Consider filtering for specific condition types related to upgrade status, such as configv1.OperatorProgressing.

func (u *OpenshiftUpgrader) GetUpgradeStatus(ctx context.Context) (string, error) {
	clusterVersion, err := u.getClusterVersion(ctx)
	if err != nil {
		return "", err
	}
	for _, condition := range clusterVersion.Status.Conditions {
-		if condition.Status == configv1.ConditionTrue {
+		if condition.Type == configv1.OperatorProgressing && condition.Status == configv1.ConditionTrue {
			return condition.Message, nil
		}
	}
	return "", nil
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Returns the cluster version's current upgrade condition message for the client's cluster.
// If any error occurs while performing this operation, it will be returned.
func (u *OpenshiftUpgrader) GetUpgradeStatus(ctx context.Context) (string, error) {
clusterVersion, err := u.getClusterVersion(ctx)
if err != nil {
return "", err
}
for _, condition := range clusterVersion.Status.Conditions {
if condition.Status == configv1.ConditionTrue {
return condition.Message, nil
}
}
return "", nil
}
// Returns the cluster version's current upgrade condition message for the client's cluster.
// If any error occurs while performing this operation, it will be returned.
func (u *OpenshiftUpgrader) GetUpgradeStatus(ctx context.Context) (string, error) {
clusterVersion, err := u.getClusterVersion(ctx)
if err != nil {
return "", err
}
for _, condition := range clusterVersion.Status.Conditions {
if condition.Type == configv1.OperatorProgressing && condition.Status == configv1.ConditionTrue {
return condition.Message, nil
}
}
return "", nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@CrystalChun is the rabbit's concern real?

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Conditions is only set to one of Available, Progressing, and Degraded for ClusterVersion from the documentation https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/config_apis/clusterversion-config-openshift-io-v1#status-4

Screenshot 2025-04-14 at 12 06 52 PM

So I didn't think we would need to check as it's all related to upgrading no matter what. However, if you prefer, I can add the type check in case this happens to change in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

So in this logic we're picking up the first message of any of those conditions and report that? Is that because they are sorted from most recent to least recent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It sounds like these are mutually exclusive, so the logic picks up any condition that's marked as true at the time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please add a little comment about this so the next person reading this code wouldn't be confused about it? 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added, thank you for the feedback!

@@ -528,6 +540,7 @@ var _ = Describe("Upgrade scenarios", func() {
condition := conditions.Get(openshiftAssistedControlPlane, controlplanev1alpha2.UpgradeCompletedCondition)
Expect(condition).NotTo(BeNil())
Expect(condition.Status).To(Equal(corev1.ConditionFalse))
Expect(condition.Message).To(Equal("upgrade to version 4.15.0 in progress\nupgrading cluster"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this message? I think it's superflous (the upgrading cluster part)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The upgrading cluster message is just a stand-in for what CVO would report back and it's going to be appended to the final message we show in our status. Do you mean I should change the message to be more relevant?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean we can omit it if everything is OK: as we already say "upgrade to version X in progress" I think there's no need to append "upgrading cluster"
In case of failure, I think adding further details is great

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gotcha! That makes sense to show only relevant information and especially not repeating things. Thanks! Removed the upgrading cluster part of the message.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 11, 2025

@CrystalChun: This pull request references MGMT-19979 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

Adds the upgrade message from the ClusterVersion in the workload cluster to the OACP's upgrade status so it's transparent to the user. Also adds a failure reason in case the upgrade fails.

Summary by CodeRabbit

  • New Features

  • Introduced a new constant for upgrade failure reasons, enhancing clarity on upgrade issues.

  • Improved upgrade status feedback with detailed messages for ongoing and failed upgrades.

  • Tests

  • Expanded test coverage validates the improved upgrade status handling and message consistency under various upgrade scenarios.

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.

Adds the upgrade message from the ClusterVersion in the
workload cluster to the OACP's upgrade status so it's
transparent to the user. Also adds a failure reason
in case the upgrade fails.
@rccrdpccl
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 15, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 51a99db into openshift-assisted:master Apr 15, 2025
8 checks passed
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants