OCPBUGS-85381: Sanitize bracketed hostnames in kubeconfig server URLs#295
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdded a ChangesHost Sanitization in Kube Client Configuration
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 11 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@bpickard22: This pull request references Jira Issue OCPBUGS-85381, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 review |
✅ Actions performedReview triggered.
|
|
@bpickard22: This pull request references Jira Issue OCPBUGS-85381, which is invalid:
Comment Retaining the jira/valid-bug label as it was manually added. DetailsIn response to this:
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. |
|
/retest-required |
During 4.13-to-4.14 upgrades, old kubeconfigs written by 4.13's entrypoint.sh contain server URLs like https://[hostname]:6443. The Go 1.24.8+ bump (CVE-2025-47912) causes net/url to reject brackets around non-IPv6 addresses. This fails every CNI DEL call during the upgrade window before multus-daemon rewrites the config. Strip brackets from non-IPv6 hostnames when reading kubeconfig files in GetK8sClient. IPv6 addresses (identified by containing colons) are preserved. Assisted by Claude Opus 4.6 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Benjamin Pickard <bpickard@redhat.com>
b578183 to
4e91ee7
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bpickard22, tsorya The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/payload-job periodic-ci-openshift-release-main-ci-4.14-upgrade-from-stable-4.13-e2e-gcp-ovn-rt-upgrade |
|
@sdodson: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command
See details on https://pr-payload-tests.ci.openshift.org/runs/ci/713923f0-4fae-11f1-9989-8be35ba84626-0 |
|
/payload-job periodic-ci-openshift-release-main-ci-4.14-upgrade-from-stable-4.13-e2e-gcp-ovn-rt-upgrade |
|
@sdodson: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command
See details on https://pr-payload-tests.ci.openshift.org/runs/ci/c0a84b50-4fd1-11f1-937f-2abac8644d2b-0 |
|
/payload-job periodic-ci-openshift-release-main-ci-4.14-upgrade-from-stable-4.13-e2e-gcp-ovn-rt-upgrade |
|
@sdodson: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command
See details on https://pr-payload-tests.ci.openshift.org/runs/ci/f1a41a10-51ff-11f1-8781-ced68785a58f-0 |
|
/verified by CI |
|
@bpickard22: Jira Issue OCPBUGS-85381: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-85381 has been moved to the MODIFIED state. DetailsIn response to this:
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. |
|
@sdodson: Jira Issue OCPBUGS-85381 is in an unrecognized state (MODIFIED) and will not be moved to the MODIFIED state. DetailsIn response to this:
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. |
|
Insights was broken until the last payload job ran, now things look much better though it still complained about how long it took to rebase the OS it looked fine otherwise. |
|
Fix included in release 4.14.0-0.nightly-2026-05-18-155714 |
Summary
GetK8sClient()to strip brackets from non-IPv6 hostnameshttps://[hostname]:6443Root cause
During 4.13-to-4.14 upgrades, there is a race window between
cnibincopy.shcopying the new multus binary andmultus-daemonstarting and rewriting the CNI config. In this window, CRI-O still has the old 4.13 CNI config ("type": "multus") and invokes the new standalone binary, which reads the old kubeconfig written by 4.13'sentrypoint.sh. That kubeconfig unconditionally wrapsKUBERNETES_SERVICE_HOSTin brackets (https://[hostname]:6443), which Go 1.24.8+net/url.Parse()now rejects for non-IPv6 addresses.This manifests as
FailedKillPoderrors (500+), stalls thedns-defaultDaemonSet rollout, causes DNS operator degradation, and fails the upgrade. Thegcp-ovn-rt-upgrade-4.14-minorblocking job has been failing for 5+ consecutive payloads.Fix
Reader-side sanitization in
GetK8sClient(): after loading a kubeconfig viaclientcmd.BuildConfigFromFlags(), strip brackets fromconfig.Hostwhen the bracketed content contains no colons (hostname or IPv4, not IPv6). This is the single code path where the standalonemultusbinary reads the kubeconfig from disk.This approach is preferred over the CNO init container approach (cluster-network-operator#3000) because:
Test plan
sanitizeBracketedHost()covering hostname, IPv4, IPv6 (digit-ending and hex-ending), loopback, no-brackets, and empty stringgo build ./pkg/k8sclient/passesgcp-ovn-rt-upgrade-4.14-minor(4.13-to-4.14 upgrade) passes with this change/cc @s1061123 @tsorya
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests