RHIDP-14785: Add OLM v1 code path to prepare-restricted-environment.sh - #3046
Conversation
PR Summary by QodoAdd OLM v1 support to install-rhdh-catalog-source.sh with auto-detection Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
Add OLM version detection and branching to the airgap script so it generates the correct manifests for both OLM v0 and OLM v1 clusters. When OLM v1 is detected (or forced via --olm-version), the script produces ClusterCatalog, ClusterExtension, ServiceAccount, and ClusterRoleBinding instead of CatalogSource, OperatorGroup, and Subscription. The oc-mirror path converts CatalogSource output to ClusterCatalog. Export-only mode generates both manifest sets. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Assisted-by: Claude (Opus 4.6)
0137c0e to
c860d35
Compare
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit c860d35 |
…m-v-1-path-to-prepare-restricted-environment-sh
…nt.sh - Introduced functions to determine whether to generate v1 or v0 manifests based on the resolved OLM version and registry settings. - Simplified conditional checks for OLM v1 and v0 manifest generation, improving code readability and maintainability. - Updated error handling for OLM installation checks to reflect the new logic.
- Introduced a variable CATALOG_PULL_SECRET to dynamically set the pull secret based on the TO_REGISTRY value. - Updated manifest generation logic to use the new CATALOG_PULL_SECRET variable, enhancing flexibility for different registry configurations. - Improved code readability by consolidating pull secret assignments.
- Updated the buildRegistryUrl function to directly execute the oc command for retrieving the default route, improving clarity. - Added a shellcheck directive to suppress warnings for the catalogImage variable assignment, enhancing code quality and maintainability.
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 5cb6ebd |
…environment.sh - Introduced a new ClusterRole for the rhdh-operator-installer, defining permissions for various Kubernetes resources. - Updated the manifest generation logic to include the new ClusterRole and adjusted the ClusterRoleBinding to reference it. - Enhanced the script to apply the ClusterRole during the installation process, improving operator functionality and security.
The prepare_olm_v1_secrets function used inline Python3 to merge internal registry credentials into the global pull secret. This introduced a python3 runtime dependency and interpolated shell variables directly into Python source code, creating a fragile injection-prone pattern. Replace with jq, which is already a standard tool in OCP environments and passes all values safely via --arg parameters. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
If detect_olm_v1_catalogd succeeded, NAMESPACE_CATALOGD should be non-empty by the time prepare_olm_v1_secrets runs. The silent fallback to "openshift-catalogd" could mask a detection inconsistency, so emit a warning instead of defaulting silently. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
Replace the sed-based URL substitution (which needed a SC2001 shellcheck disable) with yq's sub() function, consistent with how the same rewrite is done elsewhere in the script (lines 1235, 1273). Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
The opm check only verified the binary existed on PATH. An older opm could silently produce incorrect output. Now parse the version string from 'opm version' and compare against the minimum required version. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
When pushing to a non-OCP-internal registry on an OLM v1 cluster, the global pull secret merge and image-puller grants are skipped without any diagnostic. Add a debugf so users know they need to configure registry credentials themselves. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
When v1 manifests are generated during export, the user instructions now mention --olm-version v1/v0 so users know to pass it when running install.sh --from-dir on the disconnected target cluster. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
The OLM v0 manual install instructions hardcoded 'kubectl' instead of using the cli_hint variable that is already set to 'oc' or 'kubectl' based on the cluster type. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
If a previous export was interrupted (e.g. network timeout), image directories can be left in a partial state with no manifest.json. The script would then skip re-downloading (directory exists) and fail during import with a cryptic skopeo FATA error. Fix both sides: - Export: detect incomplete archives and re-download them - Import: validate manifest.json exists before pushing, with a clear error message telling the user to re-export Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
The ClusterExtension resolved the bundle but failed pre-authorization because the installer ServiceAccount was missing three permissions required by operator-controller: - namespaces: get,list,watch (core API) - clusterobjectsets/finalizers: update (olm.operatorframework.io) - /metrics: get (non-resource URL) Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
update INDEX_IMAGE="registry.redhat.io/redhat/redhat-operator-index:v4.21" Co-authored-by: Armel Soro <armel@rm3l.org>
Replace the catalogd deployment rollout check with a ClusterCatalog CRD check, as suggested by rm3l. The deployment may be scheduled but not yet ready; checking for both ClusterExtension and ClusterCatalog CRDs is sufficient to determine OLM v1 availability. Move the NAMESPACE_CATALOGD deployment lookup into prepare_olm_v1_secrets() where it is actually needed, rather than deriving it as a side effect of detection. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the opm >= 1.47 version gate that blocked source-built binaries reporting OpmVersion:"unknown". The script only uses basic opm render and opm generate dockerfile commands which work across versions. Keep the presence check via check_tool. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rewrite the one-liner boolean expressions as explicit if/return blocks so the two cases (resolved version vs export-only auto-detect) are immediately clear, as suggested by rm3l. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comment noting that oc whoami, oc get secret, and oc set data in prepare_olm_v1_secrets are OCP-specific commands with no kubectl equivalent, explaining why they use oc directly instead of invoke_cluster_cli. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The global initialization is no longer needed since the catalogd namespace lookup was moved into prepare_olm_v1_secrets() where the variable is scoped locally. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unify the duplicated cli_hint/CLI_TOOL variable into a single cli_hint set once before both the INSTALL_OPERATOR=false and INSTALL_OPERATOR=true code paths. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Hoist the CR_EXAMPLE variable (identical 12-line Backstage CR YAML) above the v1/v0 branch so it is defined once and referenced by both code paths. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The pull-secret note, patching hint, docs link, and "Developer Hub available at" URL were duplicated between the v1 and v0 output branches. Restructure so only the intro line differs between v1/v0 and the shared tail is written once. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
727bd37
into
redhat-developer:main




Adds an
--olm-version v0|v1|autoCLI flag (default:auto) toprepare-restricted-environment.shwith CRD-based OLM v1 detection. When OLM v1 is detected (or forced), the script creates a ClusterCatalog and ClusterExtension with a ServiceAccount and ClusterRoleBinding, instead of the OLM v0 CatalogSource, Subscription, and OperatorGroup. Resolution is pinned to the custom catalog viaselector.matchLabels, and CRD upgrade safety preflight is disabled (enforcement: None) per the known blocker RHIDP-8656. The OLM v0 path is fully preserved for backward compatibility on older clusters.Which issue(s) does this PR fix or relate to
Resolves: https://redhat.atlassian.net/browse/RHIDP-14785
PR acceptance criteria
How to test changes / Special notes to the reviewer
Signed-off-by: Fortune-Ndlovu fndlovu@redhat.com
Assisted-by: Claude (claude-opus-4-6)