Skip to content

[release-4.13] use net.JoinHostPort for URL construction#3005

Open
stbenjam wants to merge 1 commit into
openshift:release-4.13from
stbenjam:fix-joinhostport-4.13
Open

[release-4.13] use net.JoinHostPort for URL construction#3005
stbenjam wants to merge 1 commit into
openshift:release-4.13from
stbenjam:fix-joinhostport-4.13

Conversation

@stbenjam
Copy link
Copy Markdown
Member

Summary

Cherry-pick of commit a8f745d from release-4.14 (part of PR #2996, originally from PR #2969).

  • Replaces shell-based https://[${KUBERNETES_SERVICE_HOST}]:${KUBERNETES_SERVICE_PORT} with a Go-rendered {{.KubernetesServiceURL}} template value using net.JoinHostPort() in:
    • Multus admission controller YAML (bindata/network/multus-admission-controller/admission-controller.yaml)
    • Cloud network config controller YAML (bindata/cloud-network-config-controller/managed/controller.yaml)
  • The corresponding Go code (pkg/network/cloud_network.go, pkg/network/multus_admission_controller.go) now constructs the URL properly using net.JoinHostPort(), which only adds brackets for IPv6 addresses
  • The env var block that injected KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT into the init container is removed since the URL is now rendered directly into the template

Root cause

The previous code unconditionally wrapped KUBERNETES_SERVICE_HOST in square brackets when constructing the Kubernetes API server URL. Go 1.24.8+ (CVE-2025-47912) rejects brackets around non-IPv6 addresses, causing URL parsing failures.

Why this is needed

The 4.14 nightly gcp-ovn-rt-upgrade job upgrades from 4.13 to 4.14. The 4.13 source cluster hits this bug before the upgrade delivers the fixed 4.14 code.

Test plan

  • Verify the Go code compiles: go build ./cmd/...
  • Verify the YAML templates render correctly with hostname-based API server addresses
  • Verify the YAML templates still work correctly with IPv6 API server addresses
  • Verify 4.13 -> 4.14 upgrade succeeds

Use net.JoinHostPort() in Go code to properly handle IPv6 addresses
when constructing the Kubernetes service URL. This function correctly
adds brackets only for IPv6 addresses, ensuring compliance with
CVE-2025-47912 (Go 1.24.8+ rejects IPv4/hostnames in URL brackets).

This approach is cleaner than handling the logic in shell scripts,
as it follows the existing pattern used in ovn_kubernetes.go.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@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 May 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0b007036-5d15-41b3-9573-9819797d670b

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@stbenjam: This pull request references Jira Issue OCPBUGS-84184, which is invalid:

  • expected the bug to target either version "4.13." or "openshift-4.13.", but it targets "4.14.z" instead
  • expected the bug to be in one of the following states: NEW, ASSIGNED, POST, but it is Verified instead
  • expected dependent Jira Issue OCPBUGS-84183 to target a version in 4.14.0, 4.14.z, but it targets "4.15.z" 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:

Summary

Cherry-pick of commit a8f745d from release-4.14 (part of PR #2996, originally from PR #2969).

  • Replaces shell-based https://[${KUBERNETES_SERVICE_HOST}]:${KUBERNETES_SERVICE_PORT} with a Go-rendered {{.KubernetesServiceURL}} template value using net.JoinHostPort() in:
  • Multus admission controller YAML (bindata/network/multus-admission-controller/admission-controller.yaml)
  • Cloud network config controller YAML (bindata/cloud-network-config-controller/managed/controller.yaml)
  • The corresponding Go code (pkg/network/cloud_network.go, pkg/network/multus_admission_controller.go) now constructs the URL properly using net.JoinHostPort(), which only adds brackets for IPv6 addresses
  • The env var block that injected KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT into the init container is removed since the URL is now rendered directly into the template

Root cause

The previous code unconditionally wrapped KUBERNETES_SERVICE_HOST in square brackets when constructing the Kubernetes API server URL. Go 1.24.8+ (CVE-2025-47912) rejects brackets around non-IPv6 addresses, causing URL parsing failures.

Why this is needed

The 4.14 nightly gcp-ovn-rt-upgrade job upgrades from 4.13 to 4.14. The 4.13 source cluster hits this bug before the upgrade delivers the fixed 4.14 code.

Test plan

  • Verify the Go code compiles: go build ./cmd/...
  • Verify the YAML templates render correctly with hostname-based API server addresses
  • Verify the YAML templates still work correctly with IPv6 API server addresses
  • Verify 4.13 -> 4.14 upgrade succeeds

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 requested review from abhat and jcaamano May 12, 2026 00:51
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: stbenjam
Once this PR has been reviewed and has the lgtm label, please assign dougbtv 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

@stbenjam stbenjam changed the title OCPBUGS-84184: use net.JoinHostPort for URL construction [release-4.13] use net.JoinHostPort for URL construction May 12, 2026
@openshift-ci-robot openshift-ci-robot removed 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 May 12, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@stbenjam: No Jira issue is referenced in the title of this pull request.
To reference a jira issue, add 'XYZ-NNN:' to the title of this pull request and request another refresh with /jira refresh.

Details

In response to this:

Summary

Cherry-pick of commit a8f745d from release-4.14 (part of PR #2996, originally from PR #2969).

  • Replaces shell-based https://[${KUBERNETES_SERVICE_HOST}]:${KUBERNETES_SERVICE_PORT} with a Go-rendered {{.KubernetesServiceURL}} template value using net.JoinHostPort() in:
  • Multus admission controller YAML (bindata/network/multus-admission-controller/admission-controller.yaml)
  • Cloud network config controller YAML (bindata/cloud-network-config-controller/managed/controller.yaml)
  • The corresponding Go code (pkg/network/cloud_network.go, pkg/network/multus_admission_controller.go) now constructs the URL properly using net.JoinHostPort(), which only adds brackets for IPv6 addresses
  • The env var block that injected KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT into the init container is removed since the URL is now rendered directly into the template

Root cause

The previous code unconditionally wrapped KUBERNETES_SERVICE_HOST in square brackets when constructing the Kubernetes API server URL. Go 1.24.8+ (CVE-2025-47912) rejects brackets around non-IPv6 addresses, causing URL parsing failures.

Why this is needed

The 4.14 nightly gcp-ovn-rt-upgrade job upgrades from 4.13 to 4.14. The 4.13 source cluster hits this bug before the upgrade delivers the fixed 4.14 code.

Test plan

  • Verify the Go code compiles: go build ./cmd/...
  • Verify the YAML templates render correctly with hostname-based API server addresses
  • Verify the YAML templates still work correctly with IPv6 API server addresses
  • Verify 4.13 -> 4.14 upgrade succeeds

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
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

@stbenjam: 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-aws-ovn-windows 98d8fbc link true /test e2e-aws-ovn-windows
ci/prow/e2e-aws-sdn-network-reverse-migration 98d8fbc link true /test e2e-aws-sdn-network-reverse-migration
ci/prow/e2e-aws-sdn-network-migration-rollback 98d8fbc link true /test e2e-aws-sdn-network-migration-rollback
ci/prow/e2e-gcp-ovn 98d8fbc link true /test e2e-gcp-ovn
ci/prow/e2e-aws-ovn-network-migration 98d8fbc link true /test e2e-aws-ovn-network-migration
ci/prow/e2e-gcp-sdn 98d8fbc link true /test e2e-gcp-sdn
ci/prow/e2e-aws-sdn-multi 98d8fbc link true /test e2e-aws-sdn-multi
ci/prow/security 98d8fbc link false /test security

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants