fix issue where there is not default channel - #83177
Conversation
- jobs fails when there is not default channel set. on PreGA the default channel is not always published Signed-off-by: Eran Ifrach <eifrach@redhat.com>
WalkthroughThe install-operators command now falls back to the first available channel when no default channel exists. It reports an error only when no channel is available and logs the selected channel. ChangesOperator channel selection
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
[REHEARSALNOTIFIER]
A total of 256 jobs have been affected by this change. The above listing is non-exhaustive and limited to 25 jobs. A full list of affected jobs can be found here Interacting with pj-rehearseComment: Once you are satisfied with the results of the rehearsals, comment: |
|
/pj-rehearse ack |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@ci-operator/step-registry/install-operators/install-operators-commands.sh`:
- Around line 81-87: Update the `!default` behavior documentation in `README.md`
to state that it uses the package default channel when available and falls back
to the first available channel otherwise. Keep the existing installation
semantics and terminology consistent with the `operator_channel` fallback flow.
- Around line 83-84: Quote the packagemanifest lookup arguments in both the
default-channel and fallback lookup paths: preserve operator_name as a single
value inside the jsonpath expression and quote operator_source in the catalog
label expression so glob characters remain literal. Update the corresponding oc
invocations without changing their lookup behavior.
🪄 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: 4761372d-75c7-4150-bb11-005d3e8fc125
📒 Files selected for processing (1)
ci-operator/step-registry/install-operators/install-operators-commands.sh
| echo "WARNING: Default channel not found in '${operator_name}' packagemanifest. Falling back to the first available channel." | ||
| operator_channel=$(oc get packagemanifest \ | ||
| -l catalog=${operator_source} \ | ||
| -ojsonpath='{.items[?(.metadata.name=="'${operator_name}'")].status.channels[0].name}' 2>/dev/null || echo) | ||
| fi | ||
| if [[ -z "${operator_channel}" ]]; then | ||
| echo "ERROR: No channel found in '${operator_name}' packagemanifest." |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Document the new !default fallback behavior.
ci-operator/step-registry/install-operators/README.md Lines 68-73 says that !default installs from the package default channel. This code now selects status.channels[0].name when no default channel exists. Update the documentation to state that !default uses the default channel when available and otherwise uses the first available channel.
🧰 Tools
🪛 Shellcheck (0.11.0)
[info] 83-83: Double quote to prevent globbing and word splitting.
(SC2086)
[info] 84-84: Double quote to prevent globbing and word splitting.
(SC2086)
🤖 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 `@ci-operator/step-registry/install-operators/install-operators-commands.sh`
around lines 81 - 87, Update the `!default` behavior documentation in
`README.md` to state that it uses the package default channel when available and
falls back to the first available channel otherwise. Keep the existing
installation semantics and terminology consistent with the `operator_channel`
fallback flow.
| -l catalog=${operator_source} \ | ||
| -ojsonpath='{.items[?(.metadata.name=="'${operator_name}'")].status.channels[0].name}' 2>/dev/null || echo) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Files:"
git ls-files | rg '(^|/)install-operators-commands\.sh$|install-operators/README\.md' || true
echo
echo "Relevant command script lines:"
sed -n '1,220p' ci-operator/step-registry/install-operators/install-operators-commands.sh || true
echo
echo "Relevant README lines:"
sed -n '1,140p' ci-operator/step-registry/install-operators/README.md || trueRepository: openshift/release
Length of output: 13968
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import shlex
def current_lookup(operator_source, operator_name):
import subprocess, tempfile, os
script = f"""#!/bin/bash
set -euo pipefail
operator_source={operator_source}
operator_name={operator_name}
printf '%s\\n' "$operator_source" "$operator_name"
"""
with tempfile.NamedTemporaryFile('w', delete=False, suffix='.sh') as f:
f.write(script)
path = f.name
try:
os.chmod(path, 0o755)
return subprocess.run(['bash', path], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout
finally:
os.unlink(path)
def fixed_lookup(operator_source, operator_name):
import subprocess, tempfile, os
script = f"""#!/bin/bash
set -euo pipefail
operator_source={operator_source}
operator_name={operator_name}
printf '%s\\n' "$operator_source" "$operator_name"
"""
with tempfile.NamedTemporaryFile('w', delete=False, suffix='.sh') as f:
f.write(script)
path = f.name
try:
os.chmod(path, 0o755)
return subprocess.run(['bash', path], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout
finally:
os.unlink(path)
cases = [
"normal",
"source with space",
"**glob**",
"name space",
]
for base in cases:
print(base)
print(current_lookup(base, "pkg"))
print(fixed_lookup(base, "pkg"))
# Inspect the exact expansion paths in bash without executing repository code:
script = r'''
set -euo pipefail
operator_source='source name *'
operator_name='foo bar'
echo "expanded unquoted lines:"
printf '%s\n' "catalog=${operator_source}" "metadata.name==\""${operator_name}\"""
'''
print("direct expansion probe:")
print(subprocess.run(['bash','-c',script], text=True, stdout=subprocess.PIPE).stdout)
PYRepository: openshift/release
Length of output: 398
🏁 Script executed:
#!/bin/barRepository: openshift/release
Length of output: 155
🏁 Script executed:
#!/bin/bash
set -euo pipefail
shopt -s extglobs
echo 'Unquoted expansions'
operator_source='source name *'
operator_name='foo bar'
set -x
echo "catalog=${operator_source}"
printf '%s\n' "metadata.name==\""${operator_name}\"""
set +x
echo
echo 'Quoted expansions'
operator_source='source name *'
operator_name='foo bar'
set -x
echo "catalog=\"${operator_source}\""
printf '%s\n' "metadata.name==\"${operator_name}\""
set +xRepository: openshift/release
Length of output: 212
🏁 Script executed:
#!/bin/barRepository: openshift/release
Length of output: 155
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo 'Unquoted expansions'
operator_source='source name *'
operator_name='foo bar'
set -x
echo "catalog=${operator_source}"
printf '%s\n' "metadata.name==\""${operator_name}\"""
set +x
echo
echo 'Quoted expansions'
operator_source='source name *'
operator_name='foo bar'
set -x
echo "catalog=\"${operator_source}\""
printf '%s\n' "metadata.name==\"${operator_name}\""
set +xRepository: openshift/release
Length of output: 460
Quote the packagemanifest lookup labels and jsonpath.
If operator_name contains whitespace, the unquoted expansion inside the jsonpath expression is split before oc reads it, which can make the packagemanifest lookup fail. Apply the same quoting to operator_source to keep glob values stable in the label expression. Apply the fix to both the default-channel lookup and the fallback lookup.
🧰 Tools
🪛 Shellcheck (0.11.0)
[info] 83-83: Double quote to prevent globbing and word splitting.
(SC2086)
[info] 84-84: Double quote to prevent globbing and word splitting.
(SC2086)
🤖 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 `@ci-operator/step-registry/install-operators/install-operators-commands.sh`
around lines 83 - 84, Quote the packagemanifest lookup arguments in both the
default-channel and fallback lookup paths: preserve operator_name as a single
value inside the jsonpath expression and quote operator_source in the catalog
label expression so glob characters remain literal. Update the corresponding oc
invocations without changing their lookup behavior.
Source: Linters/SAST tools
|
/lgtm |
|
@eifrach: now processing your pj-rehearse request. Please allow up to 10 minutes for jobs to trigger or cancel. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: eifrach, rdiazcam, sg-rh The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@eifrach: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Summary by CodeRabbit
packagemanifestchannel when no default channel is published.