Skip to content

Conversation

kuiwang02
Copy link
Contributor

Only require KUBECONFIG for run-suite and run-test commands

Problem

Previously, the olmv1-tests-ext binary required the KUBECONFIG environment variable to be set for all subcommands, including those that don't
interact with a cluster (like list, info, images, update, completion, and help). This was due to an init() function in
test/qe/util/framework.go that checked KUBECONFIG during package initialization and exited immediately if it wasn't set.

Solution

This PR implements a targeted approach where only commands that actually need cluster access (run-suite and run-test) require KUBECONFIG:

  1. Removed the global init() check from test/qe/util/framework.go that was blocking all commands
  2. Added CheckKubeconfigSet() function to test/qe/util/init.go that validates KUBECONFIG and provides helpful error messages
  3. Implemented command-level validation in cmd/main.go by wrapping the RunE handlers for run-suite and run-test commands with KUBECONFIG checks

Changes

  • test/qe/util/framework.go: Removed init() function (lines 25-30)
  • test/qe/util/init.go: Added CheckKubeconfigSet() function with validation and helpful error messages
  • cmd/main.go: Added command wrapping logic to enforce KUBECONFIG requirement only for cluster-dependent commands

Testing

Verified the following behavior:

✅ Commands that work WITHOUT KUBECONFIG:
$ unset KUBECONFIG
$ ./bin/olmv1-tests-ext list --help # ✓ Works
$ ./bin/olmv1-tests-ext info # ✓ Works
$ ./bin/olmv1-tests-ext images # ✓ Works
$ ./bin/olmv1-tests-ext completion bash # ✓ Works

make update-metadata
/Users/kuiwang/GoProject/go-origin/src/github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/bin/olmv1-tests-ext update --component openshift:payload:olmv1
successfully updated metadata
/Applications/Xcode.app/Contents/Developer/usr/bin/make clean-metadata
Cleaning metadata (removing codeLocations)...

❌ Commands that REQUIRE KUBECONFIG:
$ unset KUBECONFIG
$ ./bin/olmv1-tests-ext run-suite olmv1/parallel
Error: KUBECONFIG environment variable is not set.
Please set KUBECONFIG to point to your cluster configuration file.
Example: export KUBECONFIG=/path/to/kubeconfig

$ ./bin/olmv1-tests-ext run-test "test-name"
Error: KUBECONFIG environment variable is not set.
Please set KUBECONFIG to point to your cluster configuration file.
Example: export KUBECONFIG=/path/to/kubeconfig

Assisted-by: Claude Code

/cc @perdasilva

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 9, 2025
@openshift-ci openshift-ci bot requested a review from perdasilva October 9, 2025 01:58
@openshift-ci-robot
Copy link

@kuiwang02: This pull request explicitly references no jira issue.

In response to this:

Only require KUBECONFIG for run-suite and run-test commands

Problem

Previously, the olmv1-tests-ext binary required the KUBECONFIG environment variable to be set for all subcommands, including those that don't
interact with a cluster (like list, info, images, update, completion, and help). This was due to an init() function in
test/qe/util/framework.go that checked KUBECONFIG during package initialization and exited immediately if it wasn't set.

Solution

This PR implements a targeted approach where only commands that actually need cluster access (run-suite and run-test) require KUBECONFIG:

  1. Removed the global init() check from test/qe/util/framework.go that was blocking all commands
  2. Added CheckKubeconfigSet() function to test/qe/util/init.go that validates KUBECONFIG and provides helpful error messages
  3. Implemented command-level validation in cmd/main.go by wrapping the RunE handlers for run-suite and run-test commands with KUBECONFIG checks

Changes

  • test/qe/util/framework.go: Removed init() function (lines 25-30)
  • test/qe/util/init.go: Added CheckKubeconfigSet() function with validation and helpful error messages
  • cmd/main.go: Added command wrapping logic to enforce KUBECONFIG requirement only for cluster-dependent commands

Testing

Verified the following behavior:

✅ Commands that work WITHOUT KUBECONFIG:
$ unset KUBECONFIG
$ ./bin/olmv1-tests-ext list --help # ✓ Works
$ ./bin/olmv1-tests-ext info # ✓ Works
$ ./bin/olmv1-tests-ext images # ✓ Works
$ ./bin/olmv1-tests-ext completion bash # ✓ Works

make update-metadata
/Users/kuiwang/GoProject/go-origin/src/github.com/openshift/operator-framework-operator-controller/openshift/tests-extension/bin/olmv1-tests-ext update --component openshift:payload:olmv1
successfully updated metadata
/Applications/Xcode.app/Contents/Developer/usr/bin/make clean-metadata
Cleaning metadata (removing codeLocations)...

❌ Commands that REQUIRE KUBECONFIG:
$ unset KUBECONFIG
$ ./bin/olmv1-tests-ext run-suite olmv1/parallel
Error: KUBECONFIG environment variable is not set.
Please set KUBECONFIG to point to your cluster configuration file.
Example: export KUBECONFIG=/path/to/kubeconfig

$ ./bin/olmv1-tests-ext run-test "test-name"
Error: KUBECONFIG environment variable is not set.
Please set KUBECONFIG to point to your cluster configuration file.
Example: export KUBECONFIG=/path/to/kubeconfig

Assisted-by: Claude Code

/cc @perdasilva

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.

@tmshort
Copy link
Contributor

tmshort commented Oct 9, 2025

/approve
/lgtm
Thank you

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 9, 2025
Copy link
Contributor

openshift-ci bot commented Oct 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kuiwang02, tmshort

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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 Oct 9, 2025
@kuiwang02
Copy link
Contributor Author

/verify by @kuiwang02

@kuiwang02
Copy link
Contributor Author

/verified by @kuiwang02

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Oct 9, 2025
@openshift-ci-robot
Copy link

@kuiwang02: This PR has been marked as verified by @kuiwang02.

In response to this:

/verified by @kuiwang02

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.

Copy link
Contributor

openshift-ci bot commented Oct 9, 2025

@kuiwang02: 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/okd-scos-e2e-aws-ovn eff1b24 link false /test okd-scos-e2e-aws-ovn

Full PR test history. Your PR dashboard.

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.

@openshift-merge-bot openshift-merge-bot bot merged commit 56bd7cf into openshift:main Oct 9, 2025
11 of 12 checks passed
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/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants