Skip to content

fix: prefer KUBECONFIG over in-cluster config for k8s client#1012

Open
sradco wants to merge 1 commit into
openshift:main-alerts-management-apifrom
sradco:fix-e2e-kubeconfig-fallback
Open

fix: prefer KUBECONFIG over in-cluster config for k8s client#1012
sradco wants to merge 1 commit into
openshift:main-alerts-management-apifrom
sradco:fix-e2e-kubeconfig-fallback

Conversation

@sradco

@sradco sradco commented Jun 24, 2026

Copy link
Copy Markdown

Summary

  • Fix e2e-management-api CI test failure by introducing loadKubeConfig() that prefers KUBECONFIG when set (CI/local dev) and falls back to in-cluster config (production)
  • The server previously used rest.InClusterConfig() exclusively, which connects to the build cluster in CI rather than the provisioned test cluster where PrometheusRule CRDs exist
  • This caused the management API routes to fail to register, resulting in 404 errors during e2e tests

Root Cause

The CI step monitoring-plugin-tests-management-api runs on the build cluster (build01) with KUBECONFIG pointing to the provisioned test cluster. The server used rest.InClusterConfig() which connected to the wrong cluster.

Additionally, the CI step script in openshift/release was missing the -features='alert-management-api' flag (fix submitted separately).

Test plan

  • go build ./... passes
  • go test ./pkg/... ./internal/... passes
  • go vet ./... passes
  • CI e2e-management-api test passes after openshift/release companion PR merges

Made with Cursor

The server previously used rest.InClusterConfig() exclusively, which
fails in CI where the test step pod runs on the build cluster while
KUBECONFIG points to the provisioned test cluster. This caused the
e2e-management-api tests to get 404 errors because the management
routes could not be registered without a working k8s connection.

Introduce loadKubeConfig() that prefers KUBECONFIG when set (for CI
and local development) and falls back to in-cluster config (for
production deployments).

Signed-off-by: Shirly Radco <sradco@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@sradco

sradco commented Jun 24, 2026

Copy link
Copy Markdown
Author

/retest

@simonpasquier

Copy link
Copy Markdown
Contributor

/test images

@PeterYurkovich

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 24, 2026
@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: PeterYurkovich, sradco

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 Jun 24, 2026
@PeterYurkovich

Copy link
Copy Markdown
Contributor

/retest

@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@sradco: 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-management-api f1826c6 link true /test e2e-management-api

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants