Skip to content

OTA-1959: Case 2 - oc adm upgrade recommend correctly filters out accepted risks from both sources - #2355

Open
nbottari9 wants to merge 1 commit into
openshift:mainfrom
nbottari9:1959-accept-risks-test-case-2
Open

OTA-1959: Case 2 - oc adm upgrade recommend correctly filters out accepted risks from both sources#2355
nbottari9 wants to merge 1 commit into
openshift:mainfrom
nbottari9:1959-accept-risks-test-case-2

Conversation

@nbottari9

@nbottari9 nbottari9 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

test-fixtures: add new test fixture to test oc adm upgrade recommend --version [VERSION] correctly filters out both graph- and alert-sourced risks when they're accepted.

See Case 1 (#2349)

Summary by CodeRabbit

  • New Features

    • Added example output for upgrade recommendations when known risks have been accepted.
    • Added examples showing available release channels, update versions, risk status, release details, and upgrade restrictions.
  • Tests

    • Added representative cluster configuration, feature-gate, infrastructure, alert, and upgrade-status scenarios.
    • Expanded validation to confirm recommendations for version 5.0.0-ec.5 and behavior when accepted risks are present.

… --version [VERSION]` correctly filters out both graph- and alert-sourced risks when they're accepted.

Signed-off-by: Nicholas Bottari <nbottari9@gmail.com>
@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: LGTM 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 Aug 6, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 6, 2026

Copy link
Copy Markdown

@nbottari9: This pull request references OTA-1959 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 "5.0.0" version, but no target version was set.

Details

In response to this:

test-fixtures: add new test fixture to test oc adm upgrade recommend --version [VERSION] correctly filters out both graph- and alert-sourced risks when they're accepted.

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.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Walkthrough

Changes

Accepted upgrade risks

Layer / File(s) Summary
Cluster resource fixture state
pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-cv.yaml, pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-featuregate.yaml, pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-infrastructure.yaml
Adds cluster version, feature gate, and GCP infrastructure fixtures for the risks-always scenario.
Risk evaluation and expected outputs
pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.json, pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-cv.yaml, pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.output, pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.show-outdated-releases-output, pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.version-5.0.0-ec.5-output
Adds synthetic alert data, accepted-risk recommendations, upgrade conditions, and expected CLI output for versions 5.1.0 and 5.0.0-ec.5.
Specific-version test wiring
pkg/cli/admin/upgrade/recommend/examples_test.go
Registers the fixture with the expected version 5.0.0-ec.5.

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

Possibly related PRs

  • openshift/oc#2349: Adds related oc adm upgrade recommend graph and alert risk fixtures.
  • openshift/oc#2352: Adds related fixtures and tests for CVO-handled accepted risks.

Important

Pre-merge checks failed

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

❌ Failed checks (1 error)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error New fixtures expose internal CI hostnames, private pod IPs, and a cluster-specific GCP project, including api-int.ci-ln-6tjdy82... and 10.128.0.14. Replace cluster-specific hostnames, IPs, project IDs, UUIDs, and endpoints with synthetic placeholders before committing the fixtures.
✅ Passed checks (14 passed)
Check name Status Explanation
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 The PR adds only a fixture mapping. The package uses standard Go t.Run names built from fixed fixture paths and variant labels, with no Ginkgo titles or runtime-generated values.
Test Structure And Quality ✅ Passed The change uses the existing stdlib table-driven TestExamples, not Ginkgo; it performs static mock-fixture comparisons, has diagnostic t.Fatalf/t.Errorf messages, and adds no cluster operations or...
Microshift Test Compatibility ✅ Passed The PR adds fixture data and extends a standard Go testing.T table in TestExamples; it adds no Ginkgo e2e test, so the MicroShift API check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds YAML/JSON/output fixtures and one table entry in an existing Go test; it adds no Ginkgo e2e test or multi-node/HA assumption.
Topology-Aware Scheduling Compatibility ✅ Passed The PR adds only ClusterVersion, FeatureGate, Infrastructure, alert/output fixtures, and test registration; it adds no workload manifests, controllers, or topology-sensitive scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The patch adds fixture data and one test-map entry only; no main, suite setup, or process-level stdout/logging code changed or present in the affected package.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed HEAD adds fixture data and one TestExamples map entry; it uses Go testing with local mockData os.ReadFile inputs, not Ginkgo or external network access.
No-Weak-Crypto ✅ Passed The patch adds fixture data and one test-map entry only; exact searches found no MD5, SHA-1, DES, RC4, Blowfish, ECB, crypto API, or secret-comparison usage.
Container-Privileges ✅ Passed The eight added files contain no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, allowPrivilegeEscalation, or runAs fields.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the tested command and the filtering of accepted risks from graph and alert sources.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nbottari9
Once this PR has been reviewed and has the lgtm label, please assign hongkailiu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 requested review from ardaguclu and ingvagabund August 6, 2026 17:29

@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: 1

🤖 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
`@pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.json`:
- Line 1: Rename the fixture file so its basename is
5.0.0-accepted-graph-and-alert-risks-alerts.json, matching the alert fixture
path derived by options.Complete. Preserve the existing JSON contents unchanged.
🪄 Autofix

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: Pro Plus

Run ID: e7f03290-e227-412f-b0a5-1ec374857f58

📥 Commits

Reviewing files that changed from the base of the PR and between 4773c74 and 05be48f.

📒 Files selected for processing (8)
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-cv.yaml
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-featuregate.yaml
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-infrastructure.yaml
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.json
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.output
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.show-outdated-releases-output
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.version-5.0.0-ec.5-output
  • pkg/cli/admin/upgrade/recommend/examples_test.go

@@ -0,0 +1 @@
{"status":"success","data":{"alerts":[{"labels":{"alertname":"OpenShiftUpdateRiskMightApply","namespace":"openshift-cluster-version","reason":"Alert:firing","risk":"TestAlert","severity":"warning"},"annotations":{"description":"The conditional update risk TestAlert might apply to the cluster because of Alert:firing, and the cluster update to a version exposed to the risk is not recommended. For more information refer to 'oc adm upgrade'.","runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/cluster-version-operator/OpenShiftUpdateRiskMightApply.md","summary":"The cluster might have been exposed to the conditional update risk for 15 minutes."},"state":"pending","activeAt":"2026-08-05T16:37:45.987948515Z","value":"1e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"OpenShiftUpdateRiskMightApply","namespace":"openshift-cluster-version","reason":"Match","risk":"SyntheticRiskA","severity":"warning"},"annotations":{"description":"The conditional update risk SyntheticRiskA might apply to the cluster because of Match, and the cluster update to a version exposed to the risk is not recommended. For more information refer to 'oc adm upgrade'.","runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/cluster-version-operator/OpenShiftUpdateRiskMightApply.md","summary":"The cluster might have been exposed to the conditional update risk for 15 minutes."},"state":"pending","activeAt":"2026-08-05T16:34:45.987948515Z","value":"1e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"OpenShiftUpdateRiskMightApply","namespace":"openshift-cluster-version","reason":"Match","risk":"SyntheticRiskB","severity":"warning"},"annotations":{"description":"The conditional update risk SyntheticRiskB might apply to the cluster because of Match, and the cluster update to a version exposed to the risk is not recommended. For more information refer to 'oc adm upgrade'.","runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/cluster-version-operator/OpenShiftUpdateRiskMightApply.md","summary":"The cluster might have been exposed to the conditional update risk for 15 minutes."},"state":"pending","activeAt":"2026-08-05T16:34:45.987948515Z","value":"1e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"OpenShiftUpdateRiskMightApply","namespace":"openshift-cluster-version","reason":"Match","risk":"SyntheticRiskC","severity":"warning"},"annotations":{"description":"The conditional update risk SyntheticRiskC might apply to the cluster because of Match, and the cluster update to a version exposed to the risk is not recommended. For more information refer to 'oc adm upgrade'.","runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/cluster-version-operator/OpenShiftUpdateRiskMightApply.md","summary":"The cluster might have been exposed to the conditional update risk for 15 minutes."},"state":"pending","activeAt":"2026-08-05T16:34:45.987948515Z","value":"1e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"ClusterNotUpgradeable","condition":"Upgradeable","endpoint":"metrics","name":"version","namespace":"openshift-cluster-version","severity":"info"},"annotations":{"description":"In most cases, you will still be able to apply patch releases. Reason MultipleReasons. For more information refer to 'oc adm upgrade' or https://console-openshift-console.apps.ci-ln-6tjdy82-72292.gcp-2.ci.openshift.org/settings/cluster/.","summary":"One or more cluster operators have been blocking minor or major version cluster updates for at least an hour."},"state":"pending","activeAt":"2026-08-05T15:56:40.669438478Z","value":"0e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"UpdateAvailable","channel":"risks-always","namespace":"openshift-cluster-version","severity":"info","upstream":"https://fauxinnati-fauxinnati.apps.ota-stage.q2z4.p1.openshiftapps.com/api/upgrades_info/graph?channel=risks-always\u0026version=5.0.0-ec.2\u0026arch=amd64"},"annotations":{"description":"For more information refer to 'oc adm upgrade' or https://console-openshift-console.apps.ci-ln-6tjdy82-72292.gcp-2.ci.openshift.org/settings/cluster/.","summary":"Your upstream update recommendation service recommends you update your cluster."},"state":"firing","activeAt":"2026-08-05T16:40:10.741596918Z","value":"2e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"InsightsRecommendationActive","container":"insights-operator","description":"Enabling the **TechPreviewNoUpgrade** feature set on your cluster\ncan not be undone and prevents minor version updates. Please do\nnot enable this feature set on production clusters.\n","endpoint":"https","info_link":"https://console.redhat.com/openshift/insights/advisor/clusters/d275ee16-3918-407d-8d56-981eb2ce7ae2?first=ccx_rules_ocp.external.rules.upgrade_is_blocked_due_to_tpfg%7CTECH_PREVIEW_NO_UPGRADE_FEATURE_SET_IS_ENABLED","instance":"10.128.0.14:8443","job":"metrics","namespace":"openshift-insights","pod":"insights-operator-584747df49-dznkz","service":"metrics","severity":"info","total_risk":"Important"},"annotations":{"description":"Insights recommendation \"Enabling the **TechPreviewNoUpgrade** feature set on your cluster\ncan not be undone and prevents minor version updates. Please do\nnot enable this feature set on production clusters.\n\" with total risk \"Important\" was detected on the cluster. More information is available at https://console.redhat.com/openshift/insights/advisor/clusters/d275ee16-3918-407d-8d56-981eb2ce7ae2?first=ccx_rules_ocp.external.rules.upgrade_is_blocked_due_to_tpfg%7CTECH_PREVIEW_NO_UPGRADE_FEATURE_SET_IS_ENABLED.","summary":"An Insights recommendation is active for this cluster."},"state":"firing","activeAt":"2026-08-05T15:56:45.536087262Z","value":"1e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"TechPreviewNoUpgrade","container":"kube-apiserver-operator","endpoint":"https","instance":"10.128.0.34:8443","job":"kube-apiserver-operator","name":"TechPreviewNoUpgrade","namespace":"openshift-kube-apiserver-operator","pod":"kube-apiserver-operator-7d998989dd-x9q7g","service":"metrics","severity":"warning"},"annotations":{"description":"Cluster has enabled Technology Preview features that cannot be undone and will prevent upgrades. The TechPreviewNoUpgrade feature set is not recommended on production clusters.","summary":"Cluster has enabled tech preview features that will prevent upgrades."},"state":"firing","activeAt":"2026-08-05T15:57:01.406855878Z","value":"0e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"Watchdog","namespace":"openshift-monitoring","severity":"none"},"annotations":{"description":"This is an alert meant to ensure that the entire alerting pipeline is functional.\nThis alert is always firing, therefore it should always be firing in Alertmanager\nand always fire against a receiver. There are integrations with various notification\nmechanisms that send a notification when this alert is not firing. For example the\n\"DeadMansSnitch\" integration in PagerDuty.\n","summary":"An alert that should always be firing to certify that Alertmanager is working properly."},"state":"firing","activeAt":"2026-08-05T15:56:06.311672714Z","value":"1e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"TargetDown","job":"check-endpoints","namespace":"openshift-apiserver","service":"check-endpoints","severity":"warning"},"annotations":{"description":"100% of the check-endpoints/check-endpoints targets in openshift-apiserver namespace have been unreachable for more than 15 minutes. This may be a symptom of network connectivity issues, down nodes, or failures within these components. Assess the health of the infrastructure and nodes running these targets and then contact support.","runbook_url":"https://github.com/openshift/runbooks/blob/master/alerts/cluster-monitoring-operator/TargetDown.md","summary":"Some targets were not reachable from the monitoring server for an extended period of time."},"state":"firing","activeAt":"2026-08-05T15:56:40.936046152Z","value":"1e+02","partialResponseStrategy":"WARN"},{"labels":{"alertname":"AlertmanagerReceiversNotConfigured","namespace":"openshift-monitoring","severity":"warning"},"annotations":{"description":"Alerts are not configured to be sent to a notification system, meaning that you may not be notified in a timely fashion when important failures occur. Check the OpenShift documentation to learn how to configure notifications with Alertmanager.","summary":"Receivers (notification integrations) are not configured on Alertmanager"},"state":"firing","activeAt":"2026-08-05T15:56:15.295812914Z","value":"0e+00","partialResponseStrategy":"WARN"},{"labels":{"alertname":"TestAlert","openShiftUpdatePrecheck":"true","severity":"warning"},"annotations":{"description":"Test alert for updates","summary":"Test alert for updates"},"state":"firing","activeAt":"2026-08-05T16:35:19.532828786Z","value":"1e+00","partialResponseStrategy":"WARN"}]}} No newline at end of file

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

Rename this file to the required alert fixture name.

options.Complete derives examples/5.0.0-accepted-graph-and-alert-risks-alerts.json from the ClusterVersion fixture path. The current filename does not match that path. Every test variant fails during Complete before output comparison.

Proposed rename
- pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.json
+ pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks-alerts.json
🤖 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
`@pkg/cli/admin/upgrade/recommend/examples/5.0.0-accepted-graph-and-alert-risks.json`
at line 1, Rename the fixture file so its basename is
5.0.0-accepted-graph-and-alert-risks-alerts.json, matching the alert fixture
path derived by options.Complete. Preserve the existing JSON contents unchanged.

@nbottari9

Copy link
Copy Markdown
Contributor Author

/hold

did not have the correct name for alerts file, so it was not being factored in

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 6, 2026
@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@nbottari9: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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