Skip to content

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

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

OCPBUGS-99460: Fix connectivity check for nodes named with IP address#3083
bradbehle wants to merge 2 commits 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

Summary by CodeRabbit

  • Bug Fixes

    • Improved node identifier handling for connectivity checks.
    • IPv4 and IPv6 addresses are now normalized consistently, while hostnames retain readable identifiers.
    • Preserved fallback behavior for invalid address formats.
  • Tests

    • Added coverage for hostname, IPv4, IPv6, and invalid address scenarios.

Walkthrough

Connectivity check generation now uses nodeNameForLabel for source and target labels. IP addresses replace dots and colons with hyphens. Other names retain the segment before the first dot. Unit tests cover hostname, IPv4, IPv6, and invalid IPv4 inputs.

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.
Source and target label integration
pkg/controller/connectivitycheck/connectivity_check_controller.go, pkg/controller/connectivitycheck/connectivity_check_controller_test.go
Uses nodeNameForLabel for generated source and target values. Tests cover hostname, IPv4, IPv6, and invalid IPv4 handling.

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

Suggested reviewers: miheer, pperiyasamy


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 The authored description has no Why, What, or Testing/CI section, names no automated CI lanes or platforms, and contains no bug link; the 65-line change is appropriately scoped. Add Why, What, and Testing sections with automated CNO CI jobs and platforms, and include the bug link in the PR description or title.
Commit Message Quality ❌ Error Commit 465b313, “Add requested unit tests,” has an empty body, so it violates the required body explaining why the change is needed. Squash the unit tests into the implementation commit and include a concise body that explains the testing intent and need.
E2e Tests For Feature Changes ❌ Error The controller change fixes user-facing resource naming for IP-address node names, but the full PR adds no test/e2e files and its description has no required Testing or How to verify section. Add E2E coverage and the required testing context; if E2E is not feasible, document why under How to verify it, then use @coderabbitai ignore pre-merge checks after other checks pass.
✅ 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.
Unit Tests For Go Changes ✅ Passed The PR modifies production Go code and adds pkg/controller/connectivitycheck/connectivity_check_controller_test.go with table-driven tests for nodeNameForLabel.
Rbac Least Privilege ✅ Passed The pull request changes only Go source and tests; no YAML files under bindata/ or manifests/ changed, so no RBAC rules were modified.
Docs For Feature And Behavior Changes ✅ Passed The PR is a narrow bug fix for internal connectivity-check resource naming; it adds no feature, configuration, or architecture change, so docs changes are not required.
Stale Project Docs And Config ✅ Passed The PR changes only connectivity-check Go code and tests; no docs or config files change, and searches found no affected naming contract documented in project files.
Go And Test Code Quality ✅ Passed The PR adds IPv4 and IPv6 handling with netip.ParseAddr, uses unit-aware durations, and adds no flagged logging, shadowed errors, unsafe access, t.Fatal, Sleep, or Setenv.
Ai-Generated Code Smell ✅ Passed The patch adds one focused helper, a proportional five-case table test, and a useful behavior comment; no AI markers, comment slop, or oversized unrelated tests appear.
Stable And Deterministic Test Names ✅ Passed The added t.Run titles are fixed string literals and contain no node names, IP addresses, timestamps, UUIDs, or generated suffixes.
Test Structure And Quality ✅ Passed The added test is a pure table-driven unit test with one behavior per subtest, no cluster resources or waits, and a diagnostic t.Errorf; it follows repository patterns.
Microshift Test Compatibility ✅ Passed The PR adds a standard Go testing unit test, not a Ginkgo e2e test, and it references no MicroShift-unavailable APIs, namespaces, or unsupported assumptions.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added test is a standard Go TestNodeNameForLabel unit test using testing.T; no Ginkgo e2e test or multi-node assumption was added.
Topology-Aware Scheduling Compatibility ✅ Passed The changed controller only normalizes node names used in PodNetworkConnectivityCheck resource names; its diff adds no affinity, topology spread, replica, selector, toleration, or PDB scheduling co...
Ote Binary Stdout Contract ✅ Passed The PR changes only controller logic and a unit test; no main, suite setup, klog, fmt stdout, or other process-level stdout writes were added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The only added test is a standard Go testing unit test. It adds no Ginkgo e2e test, network connection, URL, or external service dependency.
No-Weak-Crypto ✅ Passed The PR diff adds IP parsing and label formatting only; it contains no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The PR changes only Go label logic and unit tests. The complete diff adds no container/Kubernetes privilege settings, host namespaces, SYS_ADMIN, or root execution.
No-Sensitive-Data-In-Logs ✅ Passed The PR adds no production logging. It only changes node-name label generation and adds fixed-value unit tests; existing warnings are unchanged and do not log sensitive values.
Title check ✅ Passed The title uses the imperative verb "Fix," describes the connectivity-check change, and is 69 characters long.
Description check ✅ Passed The description clearly explains the node-name collision and the fix for unique connectivity-check resource names.
✨ 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 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

Comment thread pkg/controller/connectivitycheck/connectivity_check_controller.go
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]
}

@coderabbitai coderabbitai Bot Jul 21, 2026

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

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.

There are currently no unit checks of this code... it would be good to have a test that various configurations result in various PodNetworkConnectivityCheck objects being created, but the code doesn't seem set up well for unit tests right now. But you should at least add a unit test for nodeNameForLabel

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

fd --type f --extension go . pkg/controller/connectivitycheck | sort
ast-grep outline pkg/controller/connectivitycheck --items all --type function --match 'Test|nodeNameForLabel'

Length of output: 571


@danwinship, the package has no existing Go test suite. I will add connectivity_check_controller_test.go with table-driven tests for nodeNameForLabel.

One detail: the current helper can collide with a hostname-derived value. For example, both 192.0.2.10 and 192-0-2-10.example.com produce 192-0-2-10. A test that requires those outputs to differ would require a behavior change for non-IP node names. This PR states that non-IP behavior remains unchanged, so the focused test should not require that distinction.

  • Add a new focused unit-test file in pkg/controller/connectivitycheck/.
  • Test IPv4 normalization.
  • Test IPv6 normalization.
  • Test the unchanged FQDN truncation behavior.

  • 📌 Create a pull request with these changes

You are interacting with an AI system.

@danwinship danwinship changed the title Fix connectivity check for nodes named with IP address OCPBUGS-99460: Fix connectivity check for nodes named with IP address Aug 3, 2026
@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/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
Contributor

@bradbehle: This pull request references Jira Issue OCPBUGS-99460, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

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:

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.

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.

@danwinship

Copy link
Copy Markdown
Contributor

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed 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
Contributor

@danwinship: This pull request references Jira Issue OCPBUGS-99460, 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)

No GitHub users were found matching the public email listed for the QA contact in Jira (core-networking-bot@redhat.com), skipping review request.

Details

In response to this:

/jira refresh

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.

@danwinship

Copy link
Copy Markdown
Contributor

/lgtm

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

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-ovn-upgrade-ipsec
/test e2e-gcp-ovn-techpreview

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-ovn-fdp-qe
/test e2e-aws-ovn-hypershift-conformance
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-upgrade
/test e2e-aws-ovn-windows
/test e2e-azure-ovn-upgrade
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-dualstack-bgp
/test e2e-metal-ipi-ovn-dualstack-bgp-local-gw
/test e2e-metal-ipi-ovn-ipv6
/test e2e-metal-ipi-ovn-ipv6-ipsec
/test e2e-ovn-ipsec-step-registry
/test hypershift-e2e-aks

@openshift-ci

openshift-ci Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bradbehle, danwinship

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 Aug 3, 2026
@openshift-ci

openshift-ci Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@bradbehle: 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-metal-ipi-ovn-dualstack-bgp-local-gw 465b313 link true /test e2e-metal-ipi-ovn-dualstack-bgp-local-gw
ci/prow/e2e-aws-ovn-fdp-qe 465b313 link true /test e2e-aws-ovn-fdp-qe
ci/prow/5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-upgrade 465b313 link false /test 5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-upgrade
ci/prow/e2e-aws-ovn-serial-1of2 465b313 link true /test e2e-aws-ovn-serial-1of2

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.

@danwinship

Copy link
Copy Markdown
Contributor

/retest

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. 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. lgtm Indicates that a PR is ready to be merged. 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.

3 participants