Skip to content

NO-JIRA: Re-enable tests for the recommend cmd if alertsByCVO - #31440

Draft
hongkailiu wants to merge 1 commit into
openshift:mainfrom
hongkailiu:OTA-1814-re-enable
Draft

NO-JIRA: Re-enable tests for the recommend cmd if alertsByCVO#31440
hongkailiu wants to merge 1 commit into
openshift:mainfrom
hongkailiu:OTA-1814-re-enable

Conversation

@hongkailiu

@hongkailiu hongkailiu commented Jul 28, 2026

Copy link
Copy Markdown
Member

It was disabled in #31417.

Requiring openshift/oc#2322

/hold

Summary by CodeRabbit

  • Tests
    • Updated upgrade command recommendations tests to respect cluster feature-gate settings for risk/alert evaluation.
    • Adjusted expected behavior for environments including HyperShift, with branching assertions based on the feature-gate state.
    • Enhanced coverage for conditional recommendation handling and for the --version target’s accept guidance outcome.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 28, 2026
@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

It was disabled in #31417.

Requiring openshift/oc#2322

/hold

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 openshift-ci Bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 28, 2026
@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Walkthrough

The upgrade recommendation test now detects HyperShift and the FeatureGateClusterUpdateAcceptRisks setting for the target ClusterVersion, then adjusts conditional recommendation and --version expectations based on whether CVO evaluates update-accept risks.

Changes

Upgrade risk test behavior

Layer / File(s) Summary
Alert evaluation state and setup
test/extended/cli/adm_upgrade/recommend.go
Initializes shared HyperShift and alert-evaluation state, adds feature-gate lookup through alertsEvaluatedByCVO, and reuses the computed HyperShift value during setup.
Conditional recommendation expectations
test/extended/cli/adm_upgrade/recommend.go
Branches recommendation and --version assertions on alertsByCVO, retaining regex-based checks when CVO does not evaluate alerts and expecting accept guidance otherwise.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • openshift/origin#31417: Modifies the same upgrade recommendation test around alertsByCVO and HyperShift handling.

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error A new assertion logs the full oc adm upgrade recommend output on failure, which can include cluster-internal service URLs/hostnames. Avoid dumping full output; redact URLs/hostnames or log only a minimal, sanitized excerpt on failure.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: re-enabling recommend command tests when alertsByCVO is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All Ginkgo Describe/Context/It titles in the changed test file are static literals; none interpolate dynamic or run-specific data.
Test Structure And Quality ✅ Passed The added tests stay single-purpose, use bounded waits and cleanup, and follow existing adm_upgrade test patterns without introducing structural issues.
Microshift Test Compatibility ✅ Passed PASS: The whole Describe is gated by exutil.IsMicroShiftCluster()+g.Skip(), so its ClusterVersion/FeatureGate and other OpenShift API uses won’t run on MicroShift.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The changed tests only create a single update-service pod/service and query cluster APIs; no multi-node, HA, or SNO-unsafe assumptions are present.
Topology-Aware Scheduling Compatibility ✅ Passed Only an e2e CLI test file changed; no deployment manifests, controllers, replicas, affinity, node selectors, or other scheduling constraints were modified.
Ote Binary Stdout Contract ✅ Passed No process-level stdout writes were added; the file only uses framework.Logf (GinkgoWriter) and has no main/init/TestMain/BeforeSuite stdout calls.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No hardcoded IPv4 or public-internet dependency found; the update service binds on :: and uses net.JoinHostPort, with example.com only as test data.
No-Weak-Crypto ✅ Passed Changed test code only adds feature-gate logic and regex assertions; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB or custom crypto found.
Container-Privileges ✅ Passed PR only updates a Go test file; no container/K8s manifest fields like privileged, hostNetwork, or allowPrivilegeEscalation were added.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/extended/cli/adm_upgrade/recommend.go (1)

280-281: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Keep the helper comment rationale-focused.

Replace the behavior restatement and pinned implementation link with a short explanation of why HyperShift is excluded.

As per coding guidelines, Go comments should be minimal and explain why rather than what.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/extended/cli/adm_upgrade/recommend.go` around lines 280 - 281, Update
the comment for alertsEvaluatedByCVO to briefly explain why HyperShift or hosted
clusters are excluded, removing the behavior restatement and pinned upstream
implementation link.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended/cli/adm_upgrade/recommend.go`:
- Around line 243-247: Implement the CVO-specific expectation in the alertsByCVO
branch of the recommendation check: define the expected output pattern for
CVO-evaluated accept risks and assert it there instead of allowing the shared
matchRegexp call to use the legacy pattern. Preserve the existing legacy regex
path when alertsByCVO is false.
- Around line 286-289: Update the FeatureGates().Get error handling to return
false, nil when apierrors.IsNotFound(err) indicates the cluster FeatureGate
resource is missing, while continuing to return false, err for all other errors.

---

Nitpick comments:
In `@test/extended/cli/adm_upgrade/recommend.go`:
- Around line 280-281: Update the comment for alertsEvaluatedByCVO to briefly
explain why HyperShift or hosted clusters are excluded, removing the behavior
restatement and pinned upstream implementation link.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 761a1860-2775-4386-a781-fd1df64ba976

📥 Commits

Reviewing files that changed from the base of the PR and between 18c766f and 23d8c3b.

📒 Files selected for processing (1)
  • test/extended/cli/adm_upgrade/recommend.go

Comment on lines +243 to +247
if alertsByCVO {
// TODO: define the new pattern for the implementation if alertsByCVO
}
err = matchRegexp(out, pattern)
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("the actual output is \n%s", out))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Implement the CVO-enabled expectation.

The alertsByCVO branch is empty, so Line 246 still applies the legacy regex when CVO evaluates accept risks. Define and assert the CVO-specific output pattern in this branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/extended/cli/adm_upgrade/recommend.go` around lines 243 - 247, Implement
the CVO-specific expectation in the alertsByCVO branch of the recommendation
check: define the expected output pattern for CVO-evaluated accept risks and
assert it there instead of allowing the shared matchRegexp call to use the
legacy pattern. Preserve the existing legacy regex path when alertsByCVO is
false.

Comment on lines +286 to +289
featureGate, err := client.ConfigV1().FeatureGates().Get(ctx, "cluster", metav1.GetOptions{})
if err != nil {
return false, err
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect existing repository conventions for Kubernetes NotFound handling.
rg -n --type go -C2 'apierrors\.IsNotFound|FeatureGates\(\)\.Get\(' test/extended vendor/github.com/openshift

Repository: openshift/origin

Length of output: 50373


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=test/extended/cli/adm_upgrade/recommend.go

echo "== relevant slice =="
sed -n '240,320p' "$file" | cat -n

echo
echo "== imports =="
sed -n '1,60p' "$file" | cat -n

echo
echo "== function references =="
rg -n 'alertsEvaluatedByCVO|FeatureGates\(\)\.Get|apierrors\.IsNotFound|FeatureGate' "$file" test/extended/cli/adm_upgrade -C 2

Repository: openshift/origin

Length of output: 11157


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the exact function and its call sites to understand intended fallback behavior.
rg -n 'func alertsEvaluatedByCVO|alertsEvaluatedByCVO\(' test/extended/cli/adm_upgrade -C 3

Repository: openshift/origin

Length of output: 1498


🌐 Web query:

OpenShift cluster-version-operator cvo.go FeatureGateClusterUpdateAcceptRisks FeatureGates Get cluster not found disabled

💡 Result:

The FeatureGateClusterUpdateAcceptRisks is a feature gate introduced to the OpenShift Cluster Version Operator (CVO) to support the reconciliation of accepted risks during cluster updates [1][2][3]. This feature allows cluster administrators to specify accepted conditional update risks in the ClusterVersion CRD under spec.desiredUpdate.acceptRisks, provided the feature gate is enabled [1][3]. Regarding your observation of a "cluster not found" error related to feature gates in CVO: 1. Nature of the Error: In the context of the CVO and its feature gate processing, errors like 'Get "https://127.0.0.1:6443/apis/config.openshift.io/v1/featuregates/cluster": dial tcp 127.0.0.1:6443: connect: connection refused' often occur during operator startup [4]. These typically indicate that the CVO attempted to access the FeatureGate resource before the API server was fully responsive or before the informer cache had finished syncing [5][4][6]. 2. Resolution and Handling: Historically, the CVO has been updated to handle these transient failures more gracefully [7]. Recent architectural improvements have shifted FeatureGate retrieval to rely on informers rather than direct API polling [5]. If a "cluster not found" error occurs, it is frequently due to an incorrect initialization order where a 'Get' call on a lister is executed before the informer factory has been started and synchronized [6]. The fix generally involves ensuring the informer factory is fully prepared (started and synchronized) before attempting to retrieve the 'cluster' FeatureGate instance [5][6]. 3. Context for Development: If you are encountering this while modifying or debugging code in cvo.go or related packages, ensure that your logic respects the lifecycle of the controller's informer factory [6]. Using cached listers properly after ensuring cache synchronization is the standard pattern to avoid "not found" or "connection refused" errors [5][6].

Citations:


🌐 Web query:

site:github.com/openshift/cluster-version-operator FeatureGates().Get("cluster") FeatureGateClusterUpdateAcceptRisks NotFound

💡 Result:

The message "FeatureGates.Get("cluster") FeatureGateClusterUpdateAcceptRisks NotFound" refers to an interaction within the OpenShift Cluster Version Operator (CVO) [1][2]. This error (or diagnostic log) indicates that the CVO is attempting to retrieve the cluster-wide FeatureGate configuration, specifically checking for the presence or status of the FeatureGateClusterUpdateAcceptRisks feature [2][3]. Key technical context: 1. FeatureGate Interaction: The CVO uses the standard Kubernetes/OpenShift API to retrieve the "cluster" FeatureGate object [3][4]. If this object is not found (returned as a NotFound error by the API), the operator typically assumes a default state [3]. 2. Specific Feature Gate: FeatureGateClusterUpdateAcceptRisks is a feature introduced to allow the CVO to reconcile user-accepted risks during cluster updates [2]. 3. Expected Behavior: In the OpenShift architecture, if the FeatureGate object for "cluster" is not found, the operator defaults to standard behavior [3]. If you are encountering this as an error message or log entry, it generally signifies that the operator is operating under the assumption that the feature is disabled or not explicitly configured [2][3]. If you are seeing this during cluster operations, it usually indicates that the ClusterVersion Operator has successfully handled the absence of this feature gate configuration and is proceeding with default logic [3]. If the operator is failing to start or function correctly, verify the status of your FeatureGate configuration in the cluster [3].

Citations:


Treat a missing FeatureGate/cluster as disabled. Return false, nil for apierrors.IsNotFound(err) so clusters without that resource don't fail BeforeAll; keep propagating other GET errors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/extended/cli/adm_upgrade/recommend.go` around lines 286 - 289, Update
the FeatureGates().Get error handling to return false, nil when
apierrors.IsNotFound(err) indicates the cluster FeatureGate resource is missing,
while continuing to return false, err for all other errors.

Source: Learnings

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[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

Details 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 Jul 28, 2026
@hongkailiu
hongkailiu force-pushed the OTA-1814-re-enable branch from 23d8c3b to f1b04d8 Compare July 28, 2026 17:07
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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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.

2 participants