Skip to content

OCPBUGS-100052: Created new job to update vSphere nodes to have vsphere label - #497

Open
vr4manta wants to merge 1 commit into
openshift:mainfrom
vr4manta:OCPBUGS-100052
Open

OCPBUGS-100052: Created new job to update vSphere nodes to have vsphere label#497
vr4manta wants to merge 1 commit into
openshift:mainfrom
vr4manta:OCPBUGS-100052

Conversation

@vr4manta

@vr4manta vr4manta commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

OCPBUGS-100052

Changes

  • Created new job that runs during install to update existing nodes to have new label node.openshift.io/platform-type=vsphere

Notes

Idea is to have this only be attempted to run once and only on first upgrade with this change. Following upgrades should not rerun this job.

Summary by CodeRabbit

  • New Features

    • Added a one-time Kubernetes Job (vsphere-node-label-sync) to backfill missing vSphere node labels (node.openshift.io/platform-type=vsphere).
    • The job runs only when VSphereMixedNodeEnv is enabled, targets master nodes, and patches only nodes whose providerID indicates vSphere (leaving existing labels unchanged).
  • Tests

    • Added unit tests validating label backfill behavior for vSphere vs. non-vSphere clusters, already-labeled vs. missing-label nodes, nodes without providerID, and when the feature gate is disabled.
  • Chores

    • Added the new vsphere-node-label-sync-job binary to the build and included it in the runtime image.

@openshift-ci-robot openshift-ci-robot added jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jul 29, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@vr4manta: This pull request references Jira Issue OCPBUGS-100052, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

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

Details

In response to this:

OCPBUGS-100052

Changes

  • Created new job that runs during install to update existing nodes to have new label node.openshift.io/platform-type=vsphere

Notes

Idea is to have this only be attempted to run once and only on first upgrade with this change. Following upgrades should not rerun this job.

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.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3d060cde-f34e-4e30-9950-e7738cfc517a

📥 Commits

Reviewing files that changed from the base of the PR and between a3563a0 and a143234.

📒 Files selected for processing (7)
  • Dockerfile
  • Makefile
  • cmd/vsphere-node-label-sync-job/main.go
  • manifests/0000_26_cloud-controller-manager-operator_45_job-vsphere-node-label-sync.yaml
  • pkg/cloud/vsphere/vsphere.go
  • pkg/controllers/vsphere_node_label_sync.go
  • pkg/controllers/vsphere_node_label_sync_test.go

Walkthrough

The change adds a feature-gated Kubernetes Job that builds and runs a one-time synchronization pass, labeling eligible vSphere nodes. It introduces shared vSphere constants, reconciliation logic and tests, binary packaging, and deployment configuration.

Changes

vSphere node label synchronization

Layer / File(s) Summary
Label reconciliation and validation
pkg/cloud/vsphere/vsphere.go, pkg/controllers/vsphere_node_label_sync.go, pkg/controllers/vsphere_node_label_sync_test.go
Adds vSphere label/provider ID constants, labels eligible nodes when platform and feature-gate conditions match, and tests the behavior.
Job entrypoint and binary packaging
cmd/vsphere-node-label-sync-job/main.go, Makefile, Dockerfile
Initializes the one-shot synchronization flow, builds the binary, and copies it into the runtime image.
One-time Job deployment
manifests/...job-vsphere-node-label-sync.yaml
Adds a feature-gated, create-only Kubernetes Job with scheduling, host configuration, security, resources, and lifecycle settings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Job as vsphere-node-label-sync-job
  participant Config as OpenShift config informers
  participant Sync as SyncVSphereNodeLabels
  participant API as Kubernetes API

  Job->>Config: Wait for initial feature-gate state
  Job->>Sync: Start synchronization
  Sync->>API: Fetch Infrastructure and list Nodes
  Sync->>API: Patch eligible vSphere node labels
  Sync-->>Job: Return synchronization result
Loading

Suggested reviewers: nrb, damdo


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (2 errors)

Check name Status Explanation Resolution
Container-Privileges ❌ Error The new Job manifest sets hostNetwork: true, which this check explicitly flags; other hardening flags are false. Remove hostNetwork unless strictly necessary, or document/approve it as an exception in the manifest.
No-Sensitive-Data-In-Logs ❌ Error The new controller logs each patched node by name, which can expose internal hostnames. Remove node names from routine logs or gate them behind debug-only logging; prefer counts or non-identifying identifiers.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a new job that labels vSphere nodes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 No Ginkgo-style titles were added; the new test uses static t.Run names and no dynamic data in titles.
Test Structure And Quality ✅ Passed The new test is plain testing/testify, not Ginkgo; it uses a fake client, no cluster waits, and no unmanaged resources or timeout issues.
Microshift Test Compatibility ✅ Passed The new test is a plain Go unit test, not a Ginkgo e2e spec, and it doesn’t use MicroShift-unsupported OpenShift APIs/resources.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the new test is a Go unit test with t.Run and no SNO-sensitive cluster assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The new Job is gated to self-managed clusters and mirrors the existing vSphere master-node scheduling; no anti-affinity, PDB, or topology-spread constraints were added.
Ote Binary Stdout Contract ✅ Passed No process-level stdout writes found; main uses klog with stderr defaults, and suite logger defaults to stderr too.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only test change is a unit test using fake clients and no external connectivity.
No-Weak-Crypto ✅ Passed Changed files only add job/label-sync logic; scans found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, crypto imports, custom crypto, or secret/token comparisons.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
openshift-ci Bot requested a review from damdo July 29, 2026 15:50
@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign elmiko 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 requested a review from nrb July 29, 2026 15:50
@openshift-ci-robot

Copy link
Copy Markdown

@vr4manta: This pull request references Jira Issue OCPBUGS-100052, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

OCPBUGS-100052

Changes

  • Created new job that runs during install to update existing nodes to have new label node.openshift.io/platform-type=vsphere

Notes

Idea is to have this only be attempted to run once and only on first upgrade with this change. Following upgrades should not rerun this job.

Summary by CodeRabbit

  • New Features
  • Added automatic one-time synchronization of vSphere node labels.
  • vSphere nodes missing the node.openshift.io/platform-type=vsphere label are now identified and labeled when the VSphereMixedNodeEnv feature is enabled.
  • Added deployment support for running the synchronization job in the cluster.
  • Tests
  • Added coverage for vSphere, non-vSphere, already-labeled, and feature-disabled scenarios.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 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 `@cmd/vsphere-node-label-sync-job/main.go`:
- Line 75: Add an application-level timeout context derived from the context
returned by ctrl.SetupSignalHandler(), using a deadline safely below the
manifest’s 300-second limit, and ensure its cancel function is released. Pass
this context through the job’s initialization and synchronization calls so API
operations observe both termination cancellation and the application timeout;
use context.Context throughout the affected function signatures.

In
`@manifests/0000_26_cloud-controller-manager-operator_45_job-vsphere-node-label-sync.yaml`:
- Around line 46-47: Remove the hard-coded control-plane nodeSelector from the
Job manifest so scheduling is not restricted to the legacy
node-role.kubernetes.io/master label. Update the deployment scheduling
configuration to remain topology-aware and compatible with HyperShift-style
clusters, without requiring control-plane placement.
- Around line 71-97: Add a restrictive container securityContext to the
vsphere-node-label-sync container, requiring runAsNonRoot, disabling privilege
escalation, enabling a read-only root filesystem, and dropping ALL Linux
capabilities; preserve the existing host-etc-kube read-only mount and add any
other writable mounts or capabilities only if the job explicitly requires them.
- Around line 89-93: Update the container resources block in the Job manifest to
add bounded cpu and memory limits alongside the existing requests. Ensure every
container in this Kubernetes manifest defines both resource limit fields, using
values appropriate for this system-node-critical workload.
- Line 45: Remove the hostNetwork setting from the Job manifest so the
hostaccess workload uses ordinary Kubernetes Service connectivity. Ensure the
manifest retains no hostNetwork configuration while leaving its existing host
Kubernetes configuration mount unchanged.
- Line 26: Remove the ttlSecondsAfterFinished field from the Job manifest so the
completed create-only Job remains present and is not recreated on later CVO
syncs.

In `@pkg/controllers/vsphere_node_label_sync.go`:
- Line 89: Update the logging statement in the node label sync flow to avoid
emitting node.Name at info level. Replace the per-node hostname-containing
message with an aggregate/count message or a redacted identifier, while
preserving the label operation and its existing informational intent.
🪄 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: e2850ae9-15f2-41e7-bdec-611918f5192d

📥 Commits

Reviewing files that changed from the base of the PR and between 38f5e00 and 634d7eb.

📒 Files selected for processing (7)
  • Dockerfile
  • Makefile
  • cmd/vsphere-node-label-sync-job/main.go
  • manifests/0000_26_cloud-controller-manager-operator_45_job-vsphere-node-label-sync.yaml
  • pkg/cloud/vsphere/vsphere.go
  • pkg/controllers/vsphere_node_label_sync.go
  • pkg/controllers/vsphere_node_label_sync_test.go

Comment thread cmd/vsphere-node-label-sync-job/main.go Outdated
Comment thread pkg/controllers/vsphere_node_label_sync.go
@vr4manta

Copy link
Copy Markdown
Contributor Author

/retest

@vr4manta

Copy link
Copy Markdown
Contributor Author

I noticed the azure job had the following in it:

event happened 22 times, something is wrong: namespace/openshift-cloud-controller-manager-operator node/ci-op-f3bpi1wx-1a9f6-wqlfv-master-0 pod/vsphere-node-label-sync-mr9f4 hmsg/dbcbf706fd - reason/Pulled Container image "registry.build13.ci.openshift.org/ci-op-f3bpi1wx/stable@sha256:70533cbc11986458b5137dd40ffdec8370b4ccb8c037a3292ff98ddba7cc01f1" already present on machine and can be accessed by the pod (18:14:45Z) result=reject 
event happened 23 times, something is wrong: namespace/openshift-cloud-controller-manager-operator node/ci-op-f3bpi1wx-1a9f6-wqlfv-master-0 pod/vsphere-node-label-sync-mr9f4 hmsg/1f4f0000c2 - reason/Failed Error: container has runAsNonRoot and image will run as root (pod: "vsphere-node-label-sync-mr9f4_openshift-cloud-controller-manager-operator(55ee35eb-5b85-4e15-aa0f-7b9a829056f2)", container: vsphere-node-label-sync) (18:14:45Z) result=reject }

I am thinking the change coderabbit suggested for changing the run definition of the job's container may be causing this. Need to check vsphere log and retest.

@vr4manta

Copy link
Copy Markdown
Contributor Author

/test e2e-vsphere-ovn

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@cmd/vsphere-node-label-sync-job/main.go`:
- Around line 118-123: Add a ctx.Done() case to the feature-gate wait select in
main, returning through the existing graceful cancellation path when the context
is canceled while preserving the observation and timeout behavior. Ensure the
wait uses the existing context established by
ctrl.SetupSignalHandler()/jobTimeout.
🪄 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: 7850ebc2-bcbb-4bf0-af28-d6e65bc74855

📥 Commits

Reviewing files that changed from the base of the PR and between 68c2feb and a3563a0.

📒 Files selected for processing (7)
  • Dockerfile
  • Makefile
  • cmd/vsphere-node-label-sync-job/main.go
  • manifests/0000_26_cloud-controller-manager-operator_45_job-vsphere-node-label-sync.yaml
  • pkg/cloud/vsphere/vsphere.go
  • pkg/controllers/vsphere_node_label_sync.go
  • pkg/controllers/vsphere_node_label_sync_test.go

Comment thread cmd/vsphere-node-label-sync-job/main.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@pkg/controllers/vsphere_node_label_sync.go`:
- Around line 75-83: Only backfill the platform-type label when it is absent:
update the label check in the sync controller to test map membership and return
for any existing value, including non-vSphere values. In
pkg/controllers/vsphere_node_label_sync.go lines 75-83, preserve existing
labels; in pkg/controllers/vsphere_node_label_sync_test.go lines 37-75, add a
vSphere-providerID Node with a non-vSphere platform label and assert it remains
unchanged.
🪄 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: 3d060cde-f34e-4e30-9950-e7738cfc517a

📥 Commits

Reviewing files that changed from the base of the PR and between a3563a0 and a143234.

📒 Files selected for processing (7)
  • Dockerfile
  • Makefile
  • cmd/vsphere-node-label-sync-job/main.go
  • manifests/0000_26_cloud-controller-manager-operator_45_job-vsphere-node-label-sync.yaml
  • pkg/cloud/vsphere/vsphere.go
  • pkg/controllers/vsphere_node_label_sync.go
  • pkg/controllers/vsphere_node_label_sync_test.go

Comment on lines +75 to +83
if node.Labels[vsphere.NodePlatformTypeLabelKey] == vsphere.NodePlatformTypeLabelValueVSphere {
return nil
}

patch := client.MergeFrom(node.DeepCopy())
if node.Labels == nil {
node.Labels = map[string]string{}
}
node.Labels[vsphere.NodePlatformTypeLabelKey] = vsphere.NodePlatformTypeLabelValueVSphere

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Only backfill an absent platform-type label.

The sync is documented as repairing missing labels, but it overwrites any existing value other than vsphere. That can replace an established Node scheduling label.

  • pkg/controllers/vsphere_node_label_sync.go#L75-L83: check map membership and return when node.openshift.io/platform-type already exists, regardless of its value.
  • pkg/controllers/vsphere_node_label_sync_test.go#L37-L75: add a vSphere-providerID Node with an existing non-vSphere value and assert that it remains unchanged.
Proposed controller fix
- if node.Labels[vsphere.NodePlatformTypeLabelKey] == vsphere.NodePlatformTypeLabelValueVSphere {
+ if _, hasPlatformTypeLabel := node.Labels[vsphere.NodePlatformTypeLabelKey]; hasPlatformTypeLabel {
    return nil
  }
📝 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 node.Labels[vsphere.NodePlatformTypeLabelKey] == vsphere.NodePlatformTypeLabelValueVSphere {
return nil
}
patch := client.MergeFrom(node.DeepCopy())
if node.Labels == nil {
node.Labels = map[string]string{}
}
node.Labels[vsphere.NodePlatformTypeLabelKey] = vsphere.NodePlatformTypeLabelValueVSphere
if node.Labels[vsphere.NodePlatformTypeLabelKey] == vsphere.NodePlatformTypeLabelValueVSphere {
return nil
}
patch := client.MergeFrom(node.DeepCopy())
if _, hasPlatformTypeLabel := node.Labels[vsphere.NodePlatformTypeLabelKey]; hasPlatformTypeLabel {
return nil
}
node.Labels[vsphere.NodePlatformTypeLabelKey] = vsphere.NodePlatformTypeLabelValueVSphere
📍 Affects 2 files
  • pkg/controllers/vsphere_node_label_sync.go#L75-L83 (this comment)
  • pkg/controllers/vsphere_node_label_sync_test.go#L37-L75
🤖 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 `@pkg/controllers/vsphere_node_label_sync.go` around lines 75 - 83, Only
backfill the platform-type label when it is absent: update the label check in
the sync controller to test map membership and return for any existing value,
including non-vSphere values. In pkg/controllers/vsphere_node_label_sync.go
lines 75-83, preserve existing labels; in
pkg/controllers/vsphere_node_label_sync_test.go lines 37-75, add a
vSphere-providerID Node with a non-vSphere platform label and assert it remains
unchanged.

@vr4manta

Copy link
Copy Markdown
Contributor Author

/test e2e-vsphere-ovn

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@vr4manta: The following tests 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-vsphere-ovn a143234 link false /test e2e-vsphere-ovn
ci/prow/e2e-aws-ovn a143234 link true /test e2e-aws-ovn
ci/prow/level0-clusterinfra-azure-ipi-proxy-tests a143234 link false /test level0-clusterinfra-azure-ipi-proxy-tests

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants