Skip to content

install upstream nightly build of kubevirt and HCO#2178

Open
weshayutin wants to merge 2 commits intoopenshift:oadp-devfrom
weshayutin:upstream-virt
Open

install upstream nightly build of kubevirt and HCO#2178
weshayutin wants to merge 2 commits intoopenshift:oadp-devfrom
weshayutin:upstream-virt

Conversation

@weshayutin
Copy link
Copy Markdown
Contributor

@weshayutin weshayutin commented Apr 24, 2026

Why the changes were made

So leaving this to bake for a bit

How to test the changes made

Summary by CodeRabbit

  • New Features

    • Added an automated installer for the HyperConverged operator with preflight checks, catalog registration, subscription handling, CR application, and readiness waits.
    • Added an automated uninstaller for comprehensive teardown and cleanup of operator resources, workloads, storage and cluster artifacts.
  • Chores

    • Updated ignore patterns to exclude kustomize-related files.

Signed-off-by: Wesley Hayutin <weshayutin@gmail.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Walkthrough

Adds .gitignore entry for kustomize and introduces two new executable scripts under hack/install_upstream_kubevirt/: install_hco.sh to deploy HyperConverged Operator (HCO) via OLM/catalog and uninstall_hco.sh to perform comprehensive teardown and cleanup of HCO-managed resources.

Changes

Cohort / File(s) Summary
Gitignore Configuration
\.gitignore
Added ignore pattern for kustomize with a # hack virt install comment.
HCO Install Script
hack/install_upstream_kubevirt/install_hco.sh
New installer script: env var defaults, preflight tooling/auth checks, download/extract upstream HCO kustomize, create gRPC CatalogSource, poll for READY, create Namespace/OperatorGroup, apply Subscription (optionally pin startingCSV), wait for InstallPlan and operator Availability, apply HyperConverged CR (v1beta1) with optional KVM emulation JSONPatch, and poll resources for Available status.
HCO Uninstall Script
hack/install_upstream_kubevirt/uninstall_hco.sh
New uninstall script: detect HCO namespace, auth checks, patch KubeVirt/CDI uninstallStrategy, disable boot image import, delete VMs/VMIs/DataVolumes/DataImportCrons, remove HostPath Provisioner and related StorageClasses, delete image streams, delete HyperConverged CR and wait for workloads to drain, remove OLM resources (CSV/Subscription/OperatorGroup/CatalogSource), attempt cluster-scoped CRD/RBAC/webhook cleanup, delete namespaces, and reclaim PVs labeled for HPP.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as oc / curl
    participant Repo as GitHub Tarball
    participant OLM as OpenShift OLM / Catalog
    participant Operator as HCO Operator
    participant HCO as HyperConverged CR

    User->>CLI: run install_hco.sh (envs)
    CLI->>CLI: preflight checks (oc, curl, tar, auth)
    CLI->>Repo: download & extract deploy/kustomize
    CLI->>OLM: create gRPC CatalogSource in openshift-marketplace
    OLM-->>CLI: Poll until connectionState READY
    CLI->>OLM: create Namespace, OperatorGroup, Subscription (maybe startingCSV)
    OLM->>Operator: InstallPlan created -> Installed
    Operator-->>CLI: operator Deployment becomes Available
    CLI->>HCO: apply HyperConverged CR (with optional emulation patch)
    HCO-->>CLI: poll until HCO status Available
Loading
sequenceDiagram
    participant User
    participant CLI as oc / kubectl
    participant Workloads as VMs/DVs/VMIs
    participant Storage as HPP / PVs / SCs
    participant OLM as CSV/Subscription/OperatorGroup/CatalogSource
    participant Cluster as CRDs/RBAC/Webhooks

    User->>CLI: run uninstall_hco.sh
    CLI->>CLI: detect HCO namespace, auth check
    CLI->>Workloads: patch KubeVirt/CDI uninstallStrategy=RemoveWorkloads
    CLI->>Workloads: delete VMs/VMIs/DataVolumes/DataImportCrons (all namespaces)
    CLI->>Storage: delete HostPath Provisioner, StorageClasses, image streams
    Storage-->>CLI: patch PVs to nullify claimRef for reclamation
    CLI->>OLM: delete HyperConverged CR, wait for deployments/daemonsets to stop
    CLI->>OLM: remove CSVs, Subscriptions, OperatorGroups, CatalogSource
    CLI->>Cluster: attempt deletion of kubevirt-related CRDs / RBAC / webhooks
    CLI->>CLI: delete HCO and OS-images namespaces, final status check
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete. While it includes section headings matching the template, both sections contain minimal or placeholder text that does not adequately explain the changes or how to test them. Provide detailed explanation of why the installation scripts were needed, and include specific testing instructions with commands to verify the HCO and KubeVirt installations work correctly.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: introducing installation scripts for upstream nightly builds of KubeVirt and HCO, matching the changeset content.
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 PR introduces infrastructure installation scripts and .gitignore update with no Ginkgo test definitions; custom check for test stability is not applicable.
Test Structure And Quality ✅ Passed No Ginkgo test files are added or modified in this PR, making the check not applicable.
Microshift Test Compatibility ✅ Passed PR adds only bash scripts and .gitignore; no Ginkgo e2e test files introduced, so check not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR adds no new Ginkgo e2e tests, only a .gitignore update and bash scripts in hack/install_upstream_kubevirt/, so SNO compatibility test requirements do not apply.
Topology-Aware Scheduling Compatibility ✅ Passed Installation scripts create only OLM resources and minimal HyperConverged CR without scheduling constraints; actual scheduling delegated to upstream HCO operator.
Ote Binary Stdout Contract ✅ Passed PR adds infrastructure Bash scripts for HyperConverged Cluster Operator installation, not OTE binary or test code changes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not introduce any new Ginkgo e2e tests. The changes consist of a .gitignore update and two Bash utility scripts for managing HCO installations. Since no Ginkgo e2e tests are present, the check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
.gitignore (1)

50-50: Narrow ignore scope to the intended directory.

If this is meant to ignore only the repo-root install artifact, prefer /kustomize/ instead of kustomize to avoid unintentionally ignoring nested paths with the same name.

Proposed diff
- kustomize
+ /kustomize/
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore at line 50, The .gitignore entry 'kustomize' is too broad and may
ignore any nested directories named 'kustomize'; change it to the repo-root
directory form '/kustomize/' so only the intended top-level install artifact is
ignored—update the .gitignore line replacing "kustomize" with "/kustomize/" to
narrow the scope.
hack/install_upstream_kubevirt/install_hco.sh (1)

145-165: Downloaded kustomize content is not used after validation.

download_kustomize() introduces a hard GitHub dependency and extra failure path, but extracted manifests are never consumed by install steps. Either use the artifacts or drop this step.

Refactor direction
-    download_kustomize   # validates connectivity; WORK_DIR set for cleanup
     apply_catalogsource

Or, if keeping the download by design, invoke the downloaded manifest workflow so this step is functionally meaningful.

Also applies to: 449-449

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/install_hco.sh` around lines 145 - 165, The
download_kustomize() function downloads and validates kustomize manifests into
KUSTOMIZE_DIR but the extracted artifacts are never used by subsequent install
steps; either remove this function and any calls to it to eliminate the unused
GitHub dependency, or make the step functional by invoking the downloaded
workflow (e.g., execute or source KUSTOMIZE_DIR/deploy_kustomize.sh or pass
KUSTOMIZE_DIR into the install flow so later functions consume the extracted
manifests). Locate download_kustomize, the KUSTOMIZE_DIR variable and any
callers and either delete them or wire KUSTOMIZE_DIR into the install logic so
the deploy_kustomize.sh produced by download_kustomize is actually executed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@hack/install_upstream_kubevirt/install_hco.sh`:
- Around line 131-132: The current preflight cleanup uses OC_TOOL to delete all
ClusterServiceVersions in HCO_NAMESPACE which can remove unrelated operators;
change the command to target only HCO-related CSVs by removing the --all flag
and deleting by a specific identifier or label instead (e.g., use a variable
like HCO_CSV_NAME and run ${OC_TOOL} delete clusterserviceversions -n
"${HCO_NAMESPACE}" "${HCO_CSV_NAME}" --ignore-not-found 2>/dev/null || true, or
use a label selector such as ${OC_TOOL} delete clusterserviceversions -n
"${HCO_NAMESPACE}" -l <hco-specific-label> --ignore-not-found 2>/dev/null ||
true), referencing OC_TOOL, HCO_NAMESPACE and a new HCO_CSV_NAME or label to
ensure only HCO CSVs are removed.

In `@hack/install_upstream_kubevirt/uninstall_hco.sh`:
- Around line 128-131: The deletion is too broad: the existence check uses
OC_TOOL and HCO_NAMESPACE for the kubevirt-hyperconverged CR, but the removal
call uses oc_delete hyperconverged --all-namespaces --all which will erase every
HyperConverged CR cluster-wide; change the removal to target the specific CR and
namespace (use oc_delete hyperconverged kubevirt-hyperconverged -n
"${HCO_NAMESPACE}" || true) so only the checked instance is deleted, keeping
OC_TOOL, HCO_NAMESPACE, and oc_delete as the referenced symbols to locate the
lines to update.
- Around line 83-87: The uninstall script patches the wrong field: it sets
spec.enableCommonBootImageImport=false but the installer writes the flag under
spec.workloadSources.enableCommonBootImageImport; update the patch call that
uses ${OC_TOOL} patch hyperconverged kubevirt-hyperconverged (namespace
${HCO_NAMESPACE}) to target "spec.workloadSources.enableCommonBootImageImport"
instead of "spec.enableCommonBootImageImport" so the background import is
actually disabled during teardown.

---

Nitpick comments:
In @.gitignore:
- Line 50: The .gitignore entry 'kustomize' is too broad and may ignore any
nested directories named 'kustomize'; change it to the repo-root directory form
'/kustomize/' so only the intended top-level install artifact is ignored—update
the .gitignore line replacing "kustomize" with "/kustomize/" to narrow the
scope.

In `@hack/install_upstream_kubevirt/install_hco.sh`:
- Around line 145-165: The download_kustomize() function downloads and validates
kustomize manifests into KUSTOMIZE_DIR but the extracted artifacts are never
used by subsequent install steps; either remove this function and any calls to
it to eliminate the unused GitHub dependency, or make the step functional by
invoking the downloaded workflow (e.g., execute or source
KUSTOMIZE_DIR/deploy_kustomize.sh or pass KUSTOMIZE_DIR into the install flow so
later functions consume the extracted manifests). Locate download_kustomize, the
KUSTOMIZE_DIR variable and any callers and either delete them or wire
KUSTOMIZE_DIR into the install logic so the deploy_kustomize.sh produced by
download_kustomize is actually executed.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f1fdbd8b-3591-47b6-a800-5f9f58e994bf

📥 Commits

Reviewing files that changed from the base of the PR and between 5427567 and 6daf24d.

📒 Files selected for processing (3)
  • .gitignore
  • hack/install_upstream_kubevirt/install_hco.sh
  • hack/install_upstream_kubevirt/uninstall_hco.sh

Comment on lines +131 to +132
${OC_TOOL} delete clusterserviceversions \
-n "${HCO_NAMESPACE}" --all --ignore-not-found 2>/dev/null || true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Preflight cleanup deletes unrelated CSVs in the namespace.

Line 131-132 uses --all, which will remove every CSV in ${HCO_NAMESPACE}. If users override HCO_NAMESPACE, this can disrupt other operators.

Suggested fix
-        ${OC_TOOL} delete clusterserviceversions \
-            -n "${HCO_NAMESPACE}" --all --ignore-not-found 2>/dev/null || true
+        ${OC_TOOL} delete clusterserviceversions \
+            -n "${HCO_NAMESPACE}" \
+            --selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}" \
+            --ignore-not-found 2>/dev/null || true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
${OC_TOOL} delete clusterserviceversions \
-n "${HCO_NAMESPACE}" --all --ignore-not-found 2>/dev/null || true
${OC_TOOL} delete clusterserviceversions \
-n "${HCO_NAMESPACE}" \
--selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}" \
--ignore-not-found 2>/dev/null || true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/install_hco.sh` around lines 131 - 132, The
current preflight cleanup uses OC_TOOL to delete all ClusterServiceVersions in
HCO_NAMESPACE which can remove unrelated operators; change the command to target
only HCO-related CSVs by removing the --all flag and deleting by a specific
identifier or label instead (e.g., use a variable like HCO_CSV_NAME and run
${OC_TOOL} delete clusterserviceversions -n "${HCO_NAMESPACE}" "${HCO_CSV_NAME}"
--ignore-not-found 2>/dev/null || true, or use a label selector such as
${OC_TOOL} delete clusterserviceversions -n "${HCO_NAMESPACE}" -l
<hco-specific-label> --ignore-not-found 2>/dev/null || true), referencing
OC_TOOL, HCO_NAMESPACE and a new HCO_CSV_NAME or label to ensure only HCO CSVs
are removed.

Comment on lines +83 to +87
${OC_TOOL} patch hyperconverged kubevirt-hyperconverged \
-n "${HCO_NAMESPACE}" \
--type='merge' \
--patch='{"spec":{"enableCommonBootImageImport":false}}' \
|| true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Patch path for boot image import is inconsistent and likely ineffective.

Line 86 patches spec.enableCommonBootImageImport, but this PR’s installer writes that flag under spec.workloadSources.enableCommonBootImageImport (see hack/install_upstream_kubevirt/install_hco.sh, Line 385-386). That mismatch can leave background imports running during teardown.

Suggested fix
-        ${OC_TOOL} patch hyperconverged kubevirt-hyperconverged \
-            -n "${HCO_NAMESPACE}" \
-            --type='merge' \
-            --patch='{"spec":{"enableCommonBootImageImport":false}}' \
+        ${OC_TOOL} patch hyperconged kubevirt-hyperconverged \
+            -n "${HCO_NAMESPACE}" \
+            --type='merge' \
+            --patch='{"spec":{"workloadSources":{"enableCommonBootImageImport":false}}}' \
             || true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
${OC_TOOL} patch hyperconverged kubevirt-hyperconverged \
-n "${HCO_NAMESPACE}" \
--type='merge' \
--patch='{"spec":{"enableCommonBootImageImport":false}}' \
|| true
${OC_TOOL} patch hyperconverged kubevirt-hyperconverged \
-n "${HCO_NAMESPACE}" \
--type='merge' \
--patch='{"spec":{"workloadSources":{"enableCommonBootImageImport":false}}}' \
|| true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/uninstall_hco.sh` around lines 83 - 87, The
uninstall script patches the wrong field: it sets
spec.enableCommonBootImageImport=false but the installer writes the flag under
spec.workloadSources.enableCommonBootImageImport; update the patch call that
uses ${OC_TOOL} patch hyperconverged kubevirt-hyperconverged (namespace
${HCO_NAMESPACE}) to target "spec.workloadSources.enableCommonBootImageImport"
instead of "spec.enableCommonBootImageImport" so the background import is
actually disabled during teardown.

Comment on lines +128 to +131
if ${OC_TOOL} get hyperconverged kubevirt-hyperconverged \
-n "${HCO_NAMESPACE}" &>/dev/null 2>&1; then
oc_delete hyperconverged --all-namespaces --all || true
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

HyperConverged deletion scope is broader than intended.

Line 128-129 checks for kubevirt-hyperconverged in ${HCO_NAMESPACE}, but Line 130 deletes all HyperConverged CRs cluster-wide. This can remove unrelated installs.

Suggested fix
     if ${OC_TOOL} get hyperconverged kubevirt-hyperconverged \
             -n "${HCO_NAMESPACE}" &>/dev/null 2>&1; then
-        oc_delete hyperconverged --all-namespaces --all || true
+        oc_delete hyperconverged kubevirt-hyperconverged -n "${HCO_NAMESPACE}" || true
     fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ${OC_TOOL} get hyperconverged kubevirt-hyperconverged \
-n "${HCO_NAMESPACE}" &>/dev/null 2>&1; then
oc_delete hyperconverged --all-namespaces --all || true
fi
if ${OC_TOOL} get hyperconverged kubevirt-hyperconverged \
-n "${HCO_NAMESPACE}" &>/dev/null 2>&1; then
oc_delete hyperconverged kubevirt-hyperconverged -n "${HCO_NAMESPACE}" || true
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/uninstall_hco.sh` around lines 128 - 131, The
deletion is too broad: the existence check uses OC_TOOL and HCO_NAMESPACE for
the kubevirt-hyperconverged CR, but the removal call uses oc_delete
hyperconverged --all-namespaces --all which will erase every HyperConverged CR
cluster-wide; change the removal to target the specific CR and namespace (use
oc_delete hyperconverged kubevirt-hyperconverged -n "${HCO_NAMESPACE}" || true)
so only the checked instance is deleted, keeping OC_TOOL, HCO_NAMESPACE, and
oc_delete as the referenced symbols to locate the lines to update.

Signed-off-by: Wesley Hayutin <weshayutin@gmail.com>
@weshayutin weshayutin changed the title DNM: need an install path for latest openshift-virt in upstream install upstream nightly build of kubevirt and HCO Apr 27, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
hack/install_upstream_kubevirt/install_hco.sh (1)

129-132: ⚠️ Potential issue | 🟠 Major

Don't purge every CSV in the namespace.

Line 131 uses --all, so rerunning this against a shared or preexisting ${HCO_NAMESPACE} can uninstall unrelated operators. This matches the earlier finding and still needs to be scoped to HCO-owned CSVs.

Scope cleanup to the HCO subscription
-        ${OC_TOOL} delete clusterserviceversions \
-            -n "${HCO_NAMESPACE}" --all --ignore-not-found 2>/dev/null || true
+        ${OC_TOOL} delete clusterserviceversions \
+            -n "${HCO_NAMESPACE}" \
+            --selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}" \
+            --ignore-not-found 2>/dev/null || true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/install_hco.sh` around lines 129 - 132, The
script currently deletes every ClusterServiceVersion in ${HCO_NAMESPACE} using
"${OC_TOOL} delete clusterserviceversions -n \"${HCO_NAMESPACE}\" --all", which
can uninstall unrelated operators; change this to only remove CSVs
owned/installed by the HCO subscription: query the installed CSV from the
subscription (using ${OC_TOOL} get subscription \"${SUBSCRIPTION_NAME}\" -n
\"${HCO_NAMESPACE}\" and jsonpath/.status.installedCSV or otherwise filter CSVs
by an HCO-specific label/owner reference) and then delete only that CSV (or the
resulting list) instead of using --all; update the clusterserviceversions
deletion path that references ${OC_TOOL}, ${SUBSCRIPTION_NAME}, and
${HCO_NAMESPACE} to implement this scoped deletion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@hack/install_upstream_kubevirt/install_hco.sh`:
- Around line 145-165: The download_kustomize() step downloads a GitHub tarball
but its extracted KUSTOMIZE_DIR (and deploy_kustomize.sh) are never used by the
OLM install path, causing unnecessary failures on API/rate-limit errors; either
remove the download_kustomize() invocation from the main flow (so the script no
longer requires GitHub access), or make the download conditional on the
installation mode and actually consume the extracted content where needed.
Concretely, update the main script to stop calling download_kustomize() when
running the OLM installer (or drop the call entirely), or modify
download_kustomize() to return/use KUSTOMIZE_DIR/deploy_kustomize.sh in the code
paths that need it so the extraction is required only when those files will be
executed. Ensure references to KUSTOMIZE_DIR and deploy_kustomize.sh are
consistent and remove any unconditional exit-on-failure behavior if the files
are not required by the current install mode.
- Around line 326-332: The wait_for_hco_operator function currently calls
`${OC_TOOL} wait ...
--selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}"` which fails
immediately if no deployment exists; change it to first poll for at least one
matching deployment (use `${OC_TOOL} get deployments
--selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}" -n
"${HCO_NAMESPACE}"` in a retry loop with a short sleep and an overall timeout)
and only after a deployment name is found call `${OC_TOOL} wait
deployment/<found-deployment-name> -n "${HCO_NAMESPACE}"
--for=condition=Available --timeout=5m`; keep using the existing PACKAGE_NAME,
HCO_NAMESPACE and OC_TOOL variables and ensure the polling loop exits with
failure if no deployment appears before the 5m window.
- Around line 39-40: The preflight check uses `${OC_TOOL} whoami` and
`${OC_TOOL} whoami --show-server`, which fails when OC_TOOL=kubectl; update the
script to either restrict OC_TOOL to "oc" (update the comment and validate early
in preflight()) or add conditional handling in preflight(): if OC_TOOL == "oc"
keep using `whoami`/`whoami --show-server`, but if OC_TOOL == "kubectl" call
`kubectl auth whoami` for user and obtain the API server with `kubectl config
view --minify -o jsonpath={.clusters[0].cluster.server}` (or another stable
kubectl command), and ensure the doc comment for OC_TOOL is updated to reflect
supported behavior and commands. Reference: OC_TOOL variable and preflight()
checks that invoke `${OC_TOOL} whoami` and `${OC_TOOL} whoami --show-server`.

---

Duplicate comments:
In `@hack/install_upstream_kubevirt/install_hco.sh`:
- Around line 129-132: The script currently deletes every ClusterServiceVersion
in ${HCO_NAMESPACE} using "${OC_TOOL} delete clusterserviceversions -n
\"${HCO_NAMESPACE}\" --all", which can uninstall unrelated operators; change
this to only remove CSVs owned/installed by the HCO subscription: query the
installed CSV from the subscription (using ${OC_TOOL} get subscription
\"${SUBSCRIPTION_NAME}\" -n \"${HCO_NAMESPACE}\" and
jsonpath/.status.installedCSV or otherwise filter CSVs by an HCO-specific
label/owner reference) and then delete only that CSV (or the resulting list)
instead of using --all; update the clusterserviceversions deletion path that
references ${OC_TOOL}, ${SUBSCRIPTION_NAME}, and ${HCO_NAMESPACE} to implement
this scoped deletion.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f35443e4-7e3e-4f24-bc77-efb020ef7163

📥 Commits

Reviewing files that changed from the base of the PR and between 6daf24d and 9e90ed3.

📒 Files selected for processing (1)
  • hack/install_upstream_kubevirt/install_hco.sh

Comment on lines +39 to +40
# OC_TOOL oc or kubectl binary.
# (default: oc)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Does kubectl support a top-level whoamicommand likeoc whoami, and what is the supported equivalent for retrieving the current user and cluster server?

💡 Result:

No, kubectl does not support a top-level whoami command like oc whoami. The closest equivalent is kubectl auth whoami, which displays the current authenticated subject's attributes (user, groups, extras) by querying the Kubernetes API's self-subject review. This was promoted to stable in Kubernetes v1.27. For retrieving the current user and cluster server information from the kubeconfig: - Current context (including user and cluster): kubectl config current-context - Full current context details: kubectl config view --minify - Current cluster server: kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}' - Current user from kubeconfig: kubectl config view --minify -o jsonpath='{.users[0].name}' - Cluster info (API server addresses): kubectl cluster-info oc whoami (OpenShift-specific top-level command) shows the kubeconfig user name and supports flags for server/token/context, while kubectl auth whoami provides server-validated identity attributes.

Citations:


🏁 Script executed:

# First, check if the file exists and get its size
wc -l hack/install_upstream_kubevirt/install_hco.sh

# Then read the relevant sections
echo "=== Lines 35-45 (documentation) ==="
sed -n '35,45p' hack/install_upstream_kubevirt/install_hco.sh

echo "=== Lines 108-125 (preflight function with whoami) ==="
sed -n '108,125p' hack/install_upstream_kubevirt/install_hco.sh

echo "=== Lines 70-80 (to check for other usages) ==="
sed -n '70,80p' hack/install_upstream_kubevirt/install_hco.sh

echo "=== All OC_TOOL usages ==="
rg '\$\{OC_TOOL\}' hack/install_upstream_kubevirt/install_hco.sh -n

Repository: openshift/oadp-operator

Length of output: 3288


Require oc, or add real kubectl support.

Lines 112, 116–117 use ${OC_TOOL} whoami and ${OC_TOOL} whoami --show-server, but kubectl does not support these commands. The kubectl equivalent is kubectl auth whoami (stable since Kubernetes v1.27), and there is no equivalent for the --show-server flag. The script documents that OC_TOOL can be either oc or kubectl, but setting it to kubectl will fail in the preflight() check before installation even begins.

Either restrict this script to oc only, or add conditional branches to handle the different CLI tools.

Minimal fix if `oc` is the only supported client
-#   OC_TOOL           oc or kubectl binary.
-#                     (default: oc)
+#   OC_TOOL           oc binary.
+#                     (default: oc)
@@
 OC_TOOL="${OC_TOOL:-oc}"
+if [[ "${OC_TOOL}" != "oc" ]]; then
+    err "This installer currently requires 'oc'."
+    exit 1
+fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/install_hco.sh` around lines 39 - 40, The
preflight check uses `${OC_TOOL} whoami` and `${OC_TOOL} whoami --show-server`,
which fails when OC_TOOL=kubectl; update the script to either restrict OC_TOOL
to "oc" (update the comment and validate early in preflight()) or add
conditional handling in preflight(): if OC_TOOL == "oc" keep using
`whoami`/`whoami --show-server`, but if OC_TOOL == "kubectl" call `kubectl auth
whoami` for user and obtain the API server with `kubectl config view --minify -o
jsonpath={.clusters[0].cluster.server}` (or another stable kubectl command), and
ensure the doc comment for OC_TOOL is updated to reflect supported behavior and
commands. Reference: OC_TOOL variable and preflight() checks that invoke
`${OC_TOOL} whoami` and `${OC_TOOL} whoami --show-server`.

Comment on lines +145 to +165
download_kustomize() {
WORK_DIR="$(mktemp -d -t hco-kustomize-XXXXXX)"
local tarball_url="https://api.github.com/repos/kubevirt/hyperconverged-cluster-operator/tarball/${HCO_GIT_REF}"

log "Downloading HCO kustomize manifests (git ref: '${HCO_GIT_REF}')..."
(
cd "${WORK_DIR}"
curl -fsSL "${tarball_url}" \
| tar --strip-components=1 -xzf - \
--wildcards \
"kubevirt-hyperconverged-cluster-operator-*/deploy/kustomize"
)

KUSTOMIZE_DIR="${WORK_DIR}/deploy/kustomize"
if [[ ! -f "${KUSTOMIZE_DIR}/deploy_kustomize.sh" ]]; then
err "deploy_kustomize.sh not found after extraction."
err "Expected: ${KUSTOMIZE_DIR}/deploy_kustomize.sh"
exit 1
fi
log "Kustomize dir ready: ${KUSTOMIZE_DIR}"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove the unused GitHub tarball prerequisite.

download_kustomize() only validates that deploy_kustomize.sh exists; nothing ever consumes ${KUSTOMIZE_DIR} afterwards. Right now a GitHub/API outage or rate limit aborts the install even though the OLM flow does not use those manifests. Either drive the install from the extracted kustomize content or drop this step from main.

Also applies to: 456-456

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/install_hco.sh` around lines 145 - 165, The
download_kustomize() step downloads a GitHub tarball but its extracted
KUSTOMIZE_DIR (and deploy_kustomize.sh) are never used by the OLM install path,
causing unnecessary failures on API/rate-limit errors; either remove the
download_kustomize() invocation from the main flow (so the script no longer
requires GitHub access), or make the download conditional on the installation
mode and actually consume the extracted content where needed. Concretely, update
the main script to stop calling download_kustomize() when running the OLM
installer (or drop the call entirely), or modify download_kustomize() to
return/use KUSTOMIZE_DIR/deploy_kustomize.sh in the code paths that need it so
the extraction is required only when those files will be executed. Ensure
references to KUSTOMIZE_DIR and deploy_kustomize.sh are consistent and remove
any unconditional exit-on-failure behavior if the files are not required by the
current install mode.

Comment on lines +326 to +332
wait_for_hco_operator() {
log "Waiting for HCO operator deployment to be Available (timeout: 5m)..."
${OC_TOOL} wait deployments \
--selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}" \
-n "${HCO_NAMESPACE}" \
--for=condition=Available \
--timeout=5m
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

When kubectl/oc wait is invoked with --selector and no resources currently match, does it wait for resources to appear or fail immediately?

💡 Result:

When kubectl or oc wait is invoked with --selector (or -l) and no resources currently match the selector, it fails immediately with "error: no matching resources found". It does not wait for matching resources to appear. This behavior occurs because the ResourceFinder.Visit immediately returns without error (nil) when no resources match the label selector, resulting in visitCount == 0. The code then explicitly returns errNoMatchingResources unless --for=delete is specified (in which case it ignores NotFound errors). Special cases: - For --for=create, it polls until at least one matching resource is found (using PollUntilContextTimeout checking if any resource visits successfully), then proceeds to wait for conditions. A recent fix (PR #128662, merged Dec 2024 for v1.33+) ensures proper polling even with selectors by tracking found resources explicitly. - For --for=delete, it ignores NotFound errors and waits. oc wait inherits this behavior from kubectl, as confirmed by identical documentation and source patterns. Sources confirming immediate failure for standard conditions (condition=Ready, Available, etc.) with selectors when no matches: GitHub issues #96676, #1675, #87352, #66456; StackOverflow; kubectl source code (visitCount check returns errNoMatchingResources).

Citations:


Poll for the deployment to exist before waiting on its Available condition.

The oc wait command with --selector fails immediately with "no matching resources found" if no deployment matches the selector at invocation time. It does not wait for matching resources to appear. This means the function can fail immediately instead of retrying over the 5-minute timeout window.

First poll for at least one matching deployment, then invoke wait on the Available condition.

One way to make this robust
 wait_for_hco_operator() {
     log "Waiting for HCO operator deployment to be Available (timeout: 5m)..."
+    local selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}"
+    local retries=0 max_retries=20
+
+    while ! ${OC_TOOL} get deployments -n "${HCO_NAMESPACE}" -l "${selector}" -o name 2>/dev/null | grep -q .; do
+        if (( retries == max_retries )); then
+            err "Timed out waiting for HCO operator deployment to be created."
+            ${OC_TOOL} get deployments -n "${HCO_NAMESPACE}" --show-labels || true
+            exit 1
+        fi
+        (( retries += 1 ))
+        sleep 15
+    done
+
     ${OC_TOOL} wait deployments \
-        --selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}" \
+        --selector="${selector}" \
         -n "${HCO_NAMESPACE}" \
         --for=condition=Available \
         --timeout=5m
     log "HCO operator deployment is Available."
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/install_upstream_kubevirt/install_hco.sh` around lines 326 - 332, The
wait_for_hco_operator function currently calls `${OC_TOOL} wait ...
--selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}"` which fails
immediately if no deployment exists; change it to first poll for at least one
matching deployment (use `${OC_TOOL} get deployments
--selector="operators.coreos.com/${PACKAGE_NAME}.${HCO_NAMESPACE}" -n
"${HCO_NAMESPACE}"` in a retry loop with a short sleep and an overall timeout)
and only after a deployment name is found call `${OC_TOOL} wait
deployment/<found-deployment-name> -n "${HCO_NAMESPACE}"
--for=condition=Available --timeout=5m`; keep using the existing PACKAGE_NAME,
HCO_NAMESPACE and OC_TOOL variables and ensure the polling loop exits with
failure if no deployment appears before the 5m window.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 27, 2026

@weshayutin: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/4.23-e2e-test-aws 9e90ed3 link false /test 4.23-e2e-test-aws

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.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Apr 30, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kaovilai, weshayutin

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 Apr 30, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants