Skip to content

Avoid copy of the oc binary, to support heterogeneous environments#30992

Open
jogeo wants to merge 2 commits intoopenshift:mainfrom
jogeo:OCPBUGS-78090
Open

Avoid copy of the oc binary, to support heterogeneous environments#30992
jogeo wants to merge 2 commits intoopenshift:mainfrom
jogeo:OCPBUGS-78090

Conversation

@jogeo
Copy link
Copy Markdown

@jogeo jogeo commented Apr 9, 2026

Copying the oc binary around fails when the environment is a different architecture or has incompatible versions of glibc.
This change instead uses curl to connect the api endpoint, after extracting the sever and cert details from the kubeconfig.

@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: automatic mode

@openshift-ci openshift-ci bot requested review from p0lyn0mial and sjenning April 9, 2026 20:42
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 512e65b9-a996-448f-803f-d22501f02949

📥 Commits

Reviewing files that changed from the base of the PR and between a4a9c33 and a854b14.

📒 Files selected for processing (1)
  • test/extended/apiserver/kubeconfigs.go
✅ Files skipped from review due to trivial changes (1)
  • test/extended/apiserver/kubeconfigs.go

Walkthrough

Replaces copying the host oc binary into the kube-apiserver container and running oc there. Uses oc debug + exec to read the mounted kubeconfig, validate single occurrences of server, client-certificate, client-key, and certificate-authority, extract their values, and call ${server}/api?timeout=32s with curl using the extracted cert/key/CA.

Changes

Cohort / File(s) Summary
Kubeconfig validation and API check
test/extended/apiserver/kubeconfigs.go
Removed steps that copy and execute the host oc binary in the kube-apiserver container. Added oc debug + exec logic to parse the mounted kubeconfig, assert exactly one occurrence of server, client-certificate, client-key, and certificate-authority, extract their values, and perform an HTTPS curl request to the API server using the extracted cert/key/CA.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

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

openshift-ci bot commented Apr 9, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/extended/apiserver/kubeconfigs.go (1)

121-128: Use POSIX whitespace classes for better portability.

Lines 122 and 125–128 use \s in grep patterns. While this works in the current GNU grep environment, \s is not part of the POSIX standard for BRE/ERE and may not be reliable across different grep implementations or minimal container environments. Replace with [[:space:]] for guaranteed portability:

Proposed fix
-  count=$(grep -Ec "^\s*${k}:\s+" "%[1]s")
+  count=$(grep -Ec "^[[:space:]]*${k}:[[:space:]]+" "%[1]s")
   [ "$count" -eq 1 ] || { echo "expected exactly one ${k} in %[1]s, got $count" >&2; exit 1; }
 done
-server=$(grep '^\s*server:' "%[1]s" | head -1 | awk '{print $2}')
-cert=$(grep '^\s*client-certificate:' "%[1]s" | head -1 | awk '{print $2}')
-key=$(grep '^\s*client-key:' "%[1]s" | head -1 | awk '{print $2}')
-ca=$(grep '^\s*certificate-authority:' "%[1]s" | head -1 | awk '{print $2}')
+server=$(grep -E '^[[:space:]]*server:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
+cert=$(grep -E '^[[:space:]]*client-certificate:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
+key=$(grep -E '^[[:space:]]*client-key:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
+ca=$(grep -E '^[[:space:]]*certificate-authority:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/apiserver/kubeconfigs.go` around lines 121 - 128, The grep
patterns use the non-POSIX escape `\s` which can break on some grep
implementations; update the patterns in the kubeconfig validation script (the
lines that call grep -Ec "^\s*${k}:\s+" and the subsequent grep calls like grep
'^\s*server:' , grep '^\s*client-certificate:' , grep '^\s*client-key:' and grep
'^\s*certificate-authority:') to use the POSIX whitespace class `[[:space:]]`
(e.g. replace occurrences of `^\s*` and `:\s+` with the equivalent `[[:space:]]`
forms) so the checks are portable across environments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/extended/apiserver/kubeconfigs.go`:
- Line 133: The curl invocation that currently uses the
"${server}/api?timeout=32s" URL (seen in the call that builds the curl command
string in kubeconfigs.go) leaves connection/TLS and network stalls unbounded;
modify the curl command string to add explicit time limits such as
--connect-timeout 10 and --max-time 40 (or similar values) so connection
establishment and the overall request cannot hang indefinitely, ensuring the
constructed command that includes --cert "$cert" --key "$key" --cacert "$ca" and
the "${server}/api?timeout=32s" URL is updated to include these flags.

---

Nitpick comments:
In `@test/extended/apiserver/kubeconfigs.go`:
- Around line 121-128: The grep patterns use the non-POSIX escape `\s` which can
break on some grep implementations; update the patterns in the kubeconfig
validation script (the lines that call grep -Ec "^\s*${k}:\s+" and the
subsequent grep calls like grep '^\s*server:' , grep '^\s*client-certificate:' ,
grep '^\s*client-key:' and grep '^\s*certificate-authority:') to use the POSIX
whitespace class `[[:space:]]` (e.g. replace occurrences of `^\s*` and `:\s+`
with the equivalent `[[:space:]]` forms) so the checks are portable across
environments.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f545b9aa-b731-4058-b4c0-3f5eeb7dde97

📥 Commits

Reviewing files that changed from the base of the PR and between 7da3e1c and a4a9c33.

📒 Files selected for processing (1)
  • test/extended/apiserver/kubeconfigs.go

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@jogeo
Copy link
Copy Markdown
Author

jogeo commented Apr 9, 2026

/payload-job periodic-ci-openshift-release-main-ci-4.22-e2e-aws-ovn-rhcos10-techpreview

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

@jogeo: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-ci-4.22-e2e-aws-ovn-rhcos10-techpreview

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/be82cf50-345e-11f1-93cb-693c03651f0f-0

@jogeo
Copy link
Copy Markdown
Author

jogeo commented Apr 10, 2026

/retest e2e-aws-ovn-fips

@jogeo
Copy link
Copy Markdown
Author

jogeo commented Apr 10, 2026

/test e2e-aws-ovn-fips

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

@jogeo: The following test 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-fips a854b14 link true /test e2e-aws-ovn-fips

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.

@jogeo
Copy link
Copy Markdown
Author

jogeo commented Apr 10, 2026

/test e2e-aws-ovn-fips

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.

1 participant