Skip to content

[release-4.22] fix: OCPBUGS-100445: create virt-launcher NetworkPolicy on external infra cluster - #9205

Open
openshift-cherrypick-robot wants to merge 1 commit into
openshift:release-4.22from
openshift-cherrypick-robot:cherry-pick-8056-to-release-4.22
Open

[release-4.22] fix: OCPBUGS-100445: create virt-launcher NetworkPolicy on external infra cluster#9205
openshift-cherrypick-robot wants to merge 1 commit into
openshift:release-4.22from
openshift-cherrypick-robot:cherry-pick-8056-to-release-4.22

Conversation

@openshift-cherrypick-robot

Copy link
Copy Markdown

This is an automated cherry-pick of #8056

/assign dpateriya

…fra cluster

When deploying HCP KubeVirt with external infrastructure (workers on a
separate cluster), the virt-launcher NetworkPolicy was never created on
the infrastructure cluster. The reconcileNetworkPolicies function
explicitly skipped it when Credentials != nil, leaving guest VMs with
unrestricted network access to all pods and services on the infra
cluster.

This patch adds an else branch that uses the existing infra cluster
client (from KubevirtInfraClientMap) to create the virt-launcher
NetworkPolicy in the infra namespace on the infrastructure cluster.

A new reconcileVirtLauncherNetworkPolicyExternalInfra function builds
the policy adapted for external infra:
- Blocks infra cluster's clusterNetwork/serviceNetwork CIDRs
- Allows inter-VM, DNS, and ingress controller traffic
- Omits control-plane pod selectors (kube-apiserver, oauth,
  ignition-server-proxy) since those pods run on the management
  cluster and are reached via external IPs

The Network config lookup is best-effort: if the infra kubeconfig
lacks cluster-scoped get on networks.config.openshift.io, the policy
is still created but without CIDR-based egress blocking.

Also updates the documented minimum RBAC role for external infra to
include networkpolicies (networking.k8s.io) and documents the
optional ClusterRole for full network isolation.

Made-with: Cursor
@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

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: d0bd5917-f500-4ce3-b0e6-4284055b21cf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@openshift-ci
openshift-ci Bot requested review from cblecker and sjenning August 3, 2026 05:39
@openshift-ci openshift-ci Bot added area/api Indicates the PR includes changes for the API area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/documentation Indicates the PR includes changes for documentation area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/kubevirt PR/issue for KubeVirt (KubevirtPlatform) platform area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels Aug 3, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@openshift-cherrypick-robot: Jira Issue OCPBUGS-78575 has been cloned as Jira Issue OCPBUGS-100445. Will retitle bug to link to clone.
/retitle [release-4.22] fix: OCPBUGS-100445: create virt-launcher NetworkPolicy on external infra cluster

Details

In response to this:

This is an automated cherry-pick of #8056

/assign dpateriya

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.

@openshift-ci openshift-ci Bot changed the title [release-4.22] fix: OCPBUGS-78575: create virt-launcher NetworkPolicy on external infra cluster [release-4.22] fix: OCPBUGS-100445: create virt-launcher NetworkPolicy on external infra cluster Aug 3, 2026
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 3, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@openshift-cherrypick-robot: This pull request references Jira Issue OCPBUGS-100445, which is invalid:

  • expected dependent Jira Issue OCPBUGS-78575 to be in one of the following states: MODIFIED, ON_QA, VERIFIED, but it is Closed (Done) instead
  • expected dependent Jira Issue OCPBUGS-78575 to target a version in 5.0.0, but it targets "4.22.0" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

This is an automated cherry-pick of #8056

/assign dpateriya

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.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.84615% with 96 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.21%. Comparing base (f4bf3e3) to head (8762f94).
⚠️ Report is 8 commits behind head on release-4.22.

Files with missing lines Patch % Lines
...ator/controllers/hostedcluster/network_policies.go 55.77% 83 Missing and 5 partials ⚠️
...trollers/hostedcluster/hostedcluster_controller.go 16.66% 4 Missing and 1 partial ⚠️
support/conditions/conditions.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           release-4.22    #9205      +/-   ##
================================================
- Coverage         36.22%   36.21%   -0.02%     
================================================
  Files               774      774              
  Lines             94889    95018     +129     
================================================
+ Hits              34374    34409      +35     
- Misses            57699    57787      +88     
- Partials           2816     2822       +6     
Files with missing lines Coverage Δ
support/conditions/conditions.go 0.00% <0.00%> (ø)
...trollers/hostedcluster/hostedcluster_controller.go 43.71% <16.66%> (-0.05%) ⬇️
...ator/controllers/hostedcluster/network_policies.go 48.81% <55.77%> (-3.03%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@everettraven everettraven left a comment

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.

Approved from an API perspective.

/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aks-4-21
/test e2e-aws-4-21
/test e2e-aks
/test e2e-aws
/test e2e-aws-upgrade-hypershift-operator
/test e2e-azure-self-managed
/test e2e-kubevirt-aws-ovn-reduced
/test e2e-v2-aws

@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: everettraven, openshift-cherrypick-robot
Once this PR has been reviewed and has the lgtm label, please assign sjenning 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 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@openshift-cherrypick-robot: 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/e2e-aws 8762f94 link true /test e2e-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.

@cblecker

cblecker commented Aug 6, 2026

Copy link
Copy Markdown
Member

/uncc

@openshift-ci
openshift-ci Bot removed the request for review from cblecker August 6, 2026 01:33
@openshift-ci

openshift-ci Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Stale PRs are closed after 21d of inactivity.

If this PR is still relevant, comment to refresh it or remove the stale label.
Mark the PR as fresh by commenting /remove-lifecycle stale.

If this PR is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api Indicates the PR includes changes for the API area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/documentation Indicates the PR includes changes for documentation area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/kubevirt PR/issue for KubeVirt (KubevirtPlatform) platform area/testing Indicates the PR includes changes for e2e testing jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants