Skip to content

Fix connectivity check for nodes named with IP address - #3083

Open
bradbehle wants to merge 1 commit into
openshift:masterfrom
bradbehle:network-check-fix-for-node-ips
Open

Fix connectivity check for nodes named with IP address#3083
bradbehle wants to merge 1 commit into
openshift:masterfrom
bradbehle:network-check-fix-for-node-ips

Conversation

@bradbehle

Copy link
Copy Markdown
Contributor

The code that creates the PodNetworkConnectivityCheck resources to allow connection checks from network-check-source to network-check-target uses only the first part of the node name up to the first '.' This means this function is completely broken for clusters that use the IPv4 IP address as the start of the node name (like Managed OpenShift on IBM Cloud) since only one resource is created (since all the node names start with 10. or 192.)

This fix identifies these types of node names and uses the full IP address (replacing the '.' with '-') so that each resource name is unique. Its focus is narrow on purpose, so the behavior is only changed (fixed) for node names that are IP addresses and that are broken currently.

The code that creates the PodNetworkConnectivityCheck resources to
allow connection checks from network-check-source to
network-check-target uses only the first part of the node name
up to the first '.'  This means this function is completely
broken for clusters that use the IPv4 IP address as the start of
the node name (like Managed OpenShift on IBM Cloud) since only
one resource is created (since all the node names start with 10.
or 192.)

This fix identifies these types of node names and uses the full
IP address (replacing the '.' with '-') so that each resource
name is unique.  Its focus is narrow on purpose, so the behavior
is only changed (fixed) for node names that are IP addresses and
that are broken currently.
@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 Jul 21, 2026

Copy link
Copy Markdown

Walkthrough

Connectivity check generation now uses a shared helper to normalize node names for source and target labels. IP addresses replace dots and colons with hyphens, while non-IP names retain the segment before the first dot.

Changes

Connectivity check label normalization

Layer / File(s) Summary
Node label normalization
pkg/controller/connectivitycheck/connectivity_check_controller.go
Adds IP parsing and converts IP separators for label-safe identifiers while preserving hostname truncation behavior.
Source and target label wiring
pkg/controller/connectivitycheck/connectivity_check_controller.go
Uses nodeNameForLabel when generating connectivity check source and target values.

Estimated code review effort: 2 (Simple) | ~10 minutes


Caution

Pre-merge checks failed

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

  • Ignore

❌ Failed checks (3 errors)

Check name Status Explanation Resolution
Pr Quality ❌ Error Small (~20 LOC) bugfix, but the PR description lacks required Why/What/Testing sections and any issue link. Add Why/What and How to verify it/Testing with CI lanes/platforms, plus a bug/issue link in title or description.
Unit Tests For Go Changes ❌ Error pkg/controller/connectivitycheck/connectivity_check_controller.go changed, but no *_test.go files were added or modified. Add or update Go tests for the connectivity-check normalization change, or document why tests are infeasible in PR description under 'How to verify it'.
E2e Tests For Feature Changes ❌ Error Bug-fix behavior changed in pkg/controller/...go, but no test/e2e files were changed and the PR description lacks a Testing/How to verify it section. Add e2e coverage under test/e2e/ and include a Testing/How to verify it section with lanes/jobs, platform coverage, and pass status; if infeasible, document why.
✅ Passed checks (21 passed)
Check name Status Explanation
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.
Commit Message Quality ✅ Passed Single non-merge commit has a concise, descriptive subject and a body explaining why the fix was needed.
Rbac Least Privilege ✅ Passed No bindata/ or manifests/ YAML RBAC rules changed in the PR diff, so there are no new verbs/resources to review.
Docs For Feature And Behavior Changes ✅ Passed No docs/ files changed; the PR is a narrow bug fix for node-name normalization, not a new CNO feature or architecture change.
Stale Project Docs And Config ✅ Passed No docs/config mention the old node-name truncation or a moved/removed path; the touched docs only describe network diagnostics at a high level.
Go And Test Code Quality ✅ Passed Changed code only adds IP-aware node-name normalization; no logging, bare err shadowing, duration literals, or test-code issues were introduced.
Ai-Generated Code Smell ✅ Passed Only a small helper and call-site updates were added; no AI/tool references, autogenerated test blocks, or comment slop in the modified code.
Stable And Deterministic Test Names ✅ Passed No test files or Ginkgo titles were changed in this PR; only pkg/controller/connectivitycheck/connectivity_check_controller.go was modified.
Test Structure And Quality ✅ Passed PR changes only pkg/controller/connectivitycheck/connectivity_check_controller.go; no Ginkgo/_test.go files were added or modified, so the checklist is not applicable.
Microshift Test Compatibility ✅ Passed PR only changes connectivity_check_controller.go; no Ginkgo e2e tests were added or modified, so the MicroShift check is not triggered.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; only controller resource-naming logic changed, so the SNO multi-node test check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The change only normalizes PodNetworkConnectivityCheck labels; it adds no replicas, affinity, nodeSelector, topologySpread, PDB, or ControlPlaneTopology logic.
Ote Binary Stdout Contract ✅ Passed Touched code is a controller helper only; no main/init/TestMain/setup paths or stdout writes were added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo/e2e tests were added or modified; the PR only changes a controller Go file, so the IPv6/disconnected-test check is not applicable.
No-Weak-Crypto ✅ Passed The PR only changes node-label normalization in connectivity_check_controller.go; no weak crypto primitives, custom crypto, or secret comparisons are present.
Container-Privileges ✅ Passed PR only changes node-label normalization in one Go controller; no container/K8s privilege fields were added or modified.
No-Sensitive-Data-In-Logs ✅ Passed The patch only changes node-name normalization for resource names; no new logging or sensitive fields were added.
Title check ✅ Passed The title is imperative, concise, and accurately describes the connectivity check fix for IP-based node names.
Description check ✅ Passed The description directly explains the same connectivity-check naming fix and matches the changed code.
✨ 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 review from miheer and pperiyasamy July 21, 2026 19:26
@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bradbehle
Once this PR has been reviewed and has the lgtm label, please assign jcaamano 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 added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 21, 2026
@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Hi @bradbehle. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@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: 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 `@pkg/controller/connectivitycheck/connectivity_check_controller.go`:
- Around line 441-452: Add Go regression tests for nodeNameForLabel covering
bare IPv4 and IPv6 normalization, FQDN truncation to the first segment, and
distinct outputs for IP-derived versus hostname-derived identifiers. Place the
cases in the existing connectivity-check controller test suite and use
table-driven assertions; if testing is infeasible, document the justification
under “How to verify it.”
- Line 179: Update node identifier generation used by WithSource, the target
assignment near line 380, and the source/target construction around lines
441-450 so normalization remains collision-free for dotted and hyphenated
addresses such as 192.168.1.1 and 192-168-1-1. Use an encoding that preserves
separator distinctions, or explicitly detect and resolve collisions consistently
across all generated PodNetworkConnectivityCheck resources.
🪄 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 YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: c236ccbf-00a0-4951-8088-87f5e0e8f5bf

📥 Commits

Reviewing files that changed from the base of the PR and between d7ac0bd and 8ba1546.

📒 Files selected for processing (1)
  • pkg/controller/connectivitycheck/connectivity_check_controller.go

for _, template := range templates {
check := copySpecFields(template)
WithSource("network-check-source-" + strings.Split(pod.Spec.NodeName, ".")[0])(check)
WithSource("network-check-source-" + nodeNameForLabel(pod.Spec.NodeName))(check)

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 | 🏗️ Heavy lift

Ensure normalized node identifiers remain collision-free.

192.168.1.1 and 192-168-1-1 both normalize to 192-168-1-1. If both nodes exist, the source/target values used at Lines 179 and 380 can identify different nodes identically, causing generated PodNetworkConnectivityCheck resources to collide or overwrite one another. Use an encoding that preserves separator distinctions or explicitly detect and resolve collisions.

Also applies to: 380-380, 441-450

🤖 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/controller/connectivitycheck/connectivity_check_controller.go` at line
179, Update node identifier generation used by WithSource, the target assignment
near line 380, and the source/target construction around lines 441-450 so
normalization remains collision-free for dotted and hyphenated addresses such as
192.168.1.1 and 192-168-1-1. Use an encoding that preserves separator
distinctions, or explicitly detect and resolve collisions consistently across
all generated PodNetworkConnectivityCheck resources.

Comment on lines +441 to +452
// nodeNameForLabel returns a string derived from a node name that is safe to embed
// in a Kubernetes resource name. For bare IP addresses (IPv4 or IPv6), dots and
// colons are replaced with dashes so the full address is preserved and collisions
// between different IPs are avoided. For all other names (e.g. FQDNs), only the
// segment before the first dot is returned, preserving the existing behaviour.
func nodeNameForLabel(nodeName string) string {
if _, err := netip.ParseAddr(nodeName); err == nil {
return strings.NewReplacer(".", "-", ":", "-").Replace(nodeName)
}
return strings.Split(nodeName, ".")[0]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add regression tests for the normalization contract.

Cover bare IPv4, IPv6, FQDN truncation, and collisions between IP-derived and hostname-derived identifiers. No corresponding Go test change is included here; add one or document the applicable exception.

As per coding guidelines, “When production Go files under pkg/ or cmd/ change, corresponding Go test files must also be added or modified, unless the change is trivial, already covered, infeasible to test, or the justification is documented under How to verify it.”

🤖 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/controller/connectivitycheck/connectivity_check_controller.go` around
lines 441 - 452, Add Go regression tests for nodeNameForLabel covering bare IPv4
and IPv6 normalization, FQDN truncation to the first segment, and distinct
outputs for IP-derived versus hostname-derived identifiers. Place the cases in
the existing connectivity-check controller test suite and use table-driven
assertions; if testing is infeasible, document the justification under “How to
verify it.”

Source: Coding guidelines

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

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant