Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 12 additions & 28 deletions test/extended/cli/adm_upgrade/recommend.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ No updates available. You may still upgrade to a specific release image.*`)
g.Skip("HyperShift does not support configuring the upstream OpenShift Update Service directoly via ClusterVersion (it must be configured via HostedCluster on the management cluster)")
}

if alertsByCVO {
g.Skip("Skip temporarily until the implementation lands")
}

Comment on lines +136 to +139

@coderabbitai coderabbitai Bot Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate recommend.go =="
fd -a 'recommend.go$' test/extended/cli/adm_upgrade 2>/dev/null || true

echo "== file outline =="
ast-grep outline test/extended/cli/adm_upgrade/recommend.go 2>/dev/null || true

echo "== relevant sections =="
sed -n '1,170p' test/extended/cli/adm_upgrade/recommend.go
echo "== lines 200-290 =="
sed -n '200,290p' test/extended/cli/adm_upgrade/recommend.go

echo "== search alertsEvaluatedByCVO =="
rg -n "alertsEvaluatedByCVO|alertsByCVO|FeatureGate|BeforeAll|ClusterOperatorsStatus" test/extended/cli/adm_upgrade/recommend.go

echo "== git diff stat/name =="
git diff --stat 2>/dev/null || true
git diff -- test/extended/cli/adm_upgrade/recommend.go 2>/dev/null | sed -n '1,220p' || true

Repository: openshift/origin

Length of output: 14152


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Programmatic probe: simulate the helper control-flow around FeatureGates.Get result.
# Do not execute repository code or build dependencies; read source as text.
python3 - <<'PY'
from pathlib import Path
p = Path('test/extended/cli/adm_upgrade/recommend.go')
text = p.read_text()
checks = {
    "helper_exists": "FeatureGates().Get(ctx, \"cluster\"" in text,
    "found_not_found_handling_after_get": "if apierrors.IsNotFound(err)" in text
                                      and "return false, nil" in text
                                      and "FeatureGates().Get(ctx, \"cluster\"" in text,
    "found_regular_error_handling": "if err != nil" in text
                                    and "return false, err" in text
                                    and "FeatureGates().Get(ctx, \"cluster\"" in text,
    "before_all_contains_helper_call": "alertsByCVO, err" in text
                                        and "BeforeAll" in text,
}
for k, v in checks.items():
    print(f"{k}={v}")

# Print exact surrounding helper-like block if present.
lines = text.splitlines()
for i, line in enumerate(lines, 1):
    if "FeatureGates().Get(ctx" in line:
        start=max(1,i-4); end=min(len(lines),i+12)
        print(f"BLOCK_STARTS_AT línea {start}")
        for j in range(start,end+1):
            print(f"{j:04d}: {lines[j-1]}")
        break
else:
    print("no FeatureGates().Get line found")
PY

Repository: openshift/origin

Length of output: 991


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== imports/check for IsNotFound =="
rg -n "^\\s*\"k8s\\.io/apimachinery/pkg/api/errors\"|apierrors\\.IsNotFound|errors\\.NotFound|kubernetes/apimachinery/pkg/api/errors" test/extended/cli/adm_upgrade/recommend.go

echo "== alertsEvaluatedByCVO remaining lines =="
sed -n '279,305p' test/extended/cli/adm_upgrade/recommend.go

Repository: openshift/origin

Length of output: 189


Treat a missing FeatureGate/cluster as disabled.

BeforeAll calls alertsEvaluatedByCVO before the g.Skip('Skip temporarily until the implementation lands') guard. If FeatureGates().Get(ctx, "cluster", ...) returns a NotFound error, the setup currently fails. Handle apierrors.IsNotFound(err) as (false, nil) and continue to propagate other errors.

Proposed helper fix
 featureGate, err := client.ConfigV1().FeatureGates().Get(ctx, "cluster", metav1.GetOptions{})
+if apierrors.IsNotFound(err) {
+    return false, nil
+}
 if err != nil {
     return false, err
 }
🤖 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 136 - 139, Update
alertsEvaluatedByCVO to treat apierrors.IsNotFound(err) from
FeatureGates().Get(ctx, "cluster", ...) as disabled by returning (false, nil),
while continuing to return other errors unchanged; keep the existing g.Skip
guard behavior intact.

Source: Learnings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a pure revert PR to unblock 5.0 nightly payloads. The restored g.Skip("Skip temporarily until the implementation lands") guard already prevents alertsEvaluatedByCVO from being called in the relevant test scenarios, so the IsNotFound handling is not reachable in this code state.

The enhancement you suggest is reasonable for when the feature is re-implemented properly (i.e. when the g.Skip is removed again with a working oc CLI implementation), but it's out of scope for a revert. Tracked in TRT-2869.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@redhat-chai-bot, I agree that this change should remain a minimal revert and that TRT-2869 is the correct place for the enhancement.

One detail is incorrect: the outer g.BeforeAll calls alertsEvaluatedByCVO before the nested conditional-recommendations g.BeforeAll reaches the restored g.Skip. Therefore, a missing FeatureGate/cluster can still fail suite setup.

I will defer this non-revert change to TRT-2869.


🧠 Learnings used
Learnt from: hongkailiu
Repo: openshift/origin PR: 31417
File: test/extended/cli/adm_upgrade/recommend.go:283-285
Timestamp: 2026-07-28T11:06:40.515Z
Learning: In OpenShift Origin e2e tests, when looking up the `config.openshift.io/v1` `FeatureGate` named `cluster`, a “not found”/missing `FeatureGate/cluster` should be treated as “feature gate disabled” (i.e., not an error). Helper code (e.g., upgrade/CLI helpers like `alertsEvaluatedByCVO`) should distinguish NotFound from real retrieval failures and avoid propagating retrieval errors that would incorrectly fail the test when the FeatureGate resource simply doesn’t exist.

You are interacting with an AI system.

if curVer, err := semver.Parse(cv.Status.Desired.Version); err != nil {
o.Expect(err).NotTo(o.HaveOccurred())
} else {
Expand Down Expand Up @@ -224,7 +228,8 @@ No updates available. You may still upgrade to a specific release image.*`)
out, err := oc.Run("--certificate-authority", caBundleFilePath, "adm", "upgrade", "recommend").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_PRECHECK", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_ACCEPT", "true").Output()
o.Expect(err).NotTo(o.HaveOccurred())

pattern := `The following conditions found no cause for concern in updating this cluster to later releases.*
// TODO: define the new pattern for the implementation if alertsByCVO
err = matchRegexp(out, `The following conditions found no cause for concern in updating this cluster to later releases.*

Upstream update service: http://.*
Channel: test-channel [(]available channels: other-channel, test-channel[)]
Expand All @@ -239,25 +244,8 @@ Updates to 4[.][0-9]*:
Updates to 4[.][0-9]*:
VERSION *ISSUES
4[.][0-9]*[.]999 *no known issues relevant to this cluster
4[.][0-9]*[.]998 *no known issues relevant to this cluster`
if alertsByCVO {
pattern = `Upstream update service: http://.*
Channel: test-channel [(]available channels: other-channel, test-channel[)]

Updates to 4[.][0-9]*:

Version: 4[.][0-9]*[.]0
Image: example[.]com/test@sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
Reason: (TestRiskA|MultipleReasons)
Message: (?s:.*)This is a test risk[.] https://example[.]com/testRiskA

Updates to 4[.][0-9]*:
VERSION *ISSUES
4[.][0-9]*[.]999 *no known issues relevant to this cluster
4[.][0-9]*[.]998 *no known issues relevant to this cluster`
}
err = matchRegexp(out, pattern)
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("the actual output is \n%s", out))
4[.][0-9]*[.]998 *no known issues relevant to this cluster`)
o.Expect(err).NotTo(o.HaveOccurred())
})
})

Expand All @@ -267,12 +255,9 @@ Updates to 4[.][0-9]*:
o.Expect(oc.Run("config", "set-context").Args("--current", "--user", "test").Execute()).To(o.Succeed())

out, err := oc.Run("--certificate-authority", caBundleFilePath, "adm", "upgrade", "recommend", "--version", fmt.Sprintf("4.%d.0", currentVersion.Minor+1), "--accept", "ConditionalUpdateRisk,Failing").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_PRECHECK", "true").EnvVar("OC_ENABLE_CMD_UPGRADE_RECOMMEND_ACCEPT", "true").Output()
if alertsByCVO {
o.Expect(err).NotTo(o.BeNil())
o.Expect(err.Error()).To(o.ContainSubstring("`oc adm upgrade accept` can be used to accept them"))
} else {
o.Expect(err).NotTo(o.HaveOccurred())
err = matchRegexp(out, `The following conditions found no cause for concern in updating this cluster to later releases.*
// TODO: expect an error to occur if alertsByCVO; the error directs the user to use `oc adm upgrade accept command`.
o.Expect(err).NotTo(o.HaveOccurred())
err = matchRegexp(out, `The following conditions found no cause for concern in updating this cluster to later releases.*

Upstream update service: http://.*
Channel: test-channel [(]available channels: other-channel, test-channel[)]
Expand All @@ -283,8 +268,7 @@ Release URL: https://example.com/release/4[.][0-9]*[.]0
Reason: accepted (TestRiskA|MultipleReasons) via ConditionalUpdateRisk
Message: (?s:.*)This is a test risk[.] https://example.com/testRiskA
Update to 4[.][0-9]*[.]0 has no known issues relevant to this cluster other than the accepted ConditionalUpdateRisk(|,Failing).`)
o.Expect(err).NotTo(o.HaveOccurred())
}
o.Expect(err).NotTo(o.HaveOccurred())
})
})
})
Expand Down