Skip to content

TRT-2652: Allow OTE info and list tests commands to work without KUBECONFIG#3170

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
petr-muller:fix-info-without-kubeconfig
May 12, 2026
Merged

TRT-2652: Allow OTE info and list tests commands to work without KUBECONFIG#3170
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
petr-muller:fix-info-without-kubeconfig

Conversation

@petr-muller
Copy link
Copy Markdown
Member

@petr-muller petr-muller commented Apr 30, 2026

Summary

Make getKubeConfig() failure non-fatal in the ovn-kubernetes-tests-ext binary's main(). When KUBECONFIG is absent, ocpInfra stays nil and shouldIncludeTest() includes all eligible tests without cluster-dependent filtering (e.g. EVPN checks). The AddBeforeAll guard ensures that actually running tests still requires KUBECONFIG.

This enables workflows that need to discover or list tests from ovn-kubernetes without a live cluster connection, such as the openshift-tests list all-tests command being added in openshift/origin#31105.

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Test discovery/listing works without a configured cluster; environment-less runs no longer apply capability-dependent filters.
    • Test execution now fails early when kubeconfig or cluster configuration is unavailable, preventing partial/invalid runs.
    • Cluster initialization is performed conditionally, avoiding unnecessary infra setup errors during list/info style operations.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 30, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Walkthrough

Kubeconfig retrieval is made conditional: when kubeconfig retrieval fails ocpInfra stays nil. shouldIncludeTest now short-circuits to include tests if ocpInfra is nil, bypassing capability-based label filtering. Ginkgo's BeforeAll panics on kubeconfig or infra creation errors before initializing the test framework.

Changes

Kubeconfig & Test Filtering

Layer / File(s) Summary
Kubeconfig retrieval & infra wiring
openshift/cmd/ovn-kubernetes-tests-ext/main.go
Call getKubeConfig() and only construct/set ocpInfra / infra providers when kubeconfig retrieval succeeds (cfgErr == nil); otherwise leave ocpInfra nil and capture infraErr.
Test inclusion logic
openshift/cmd/ovn-kubernetes-tests-ext/main.go
shouldIncludeTest now returns true if ocpInfra == nil after existing lifecycle/disabled-name checks, avoiding capability-dependent label checks when infra is unavailable.
Ginkgo BeforeAll / framework init
openshift/cmd/ovn-kubernetes-tests-ext/main.go
specs.AddBeforeAll now panics inside the before-all hook when cfgErr != nil or infraErr != nil, and only then calls initializeTestFramework(TEST_PROVIDER, cfg), separating list/info execution from full test execution.
Module metadata
go.mod
Module file present; no exported API changes.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant Kubeconfig
    participant InfraProvider
    participant GinkgoBeforeAll
    participant TestFramework

    CLI->>Kubeconfig: getKubeConfig()
    alt kubeconfig succeeds
        Kubeconfig->>InfraProvider: create ocpInfra / providers
        CLI->>GinkgoBeforeAll: register BeforeAll (cfgErr=nil, infraErr=nil)
        GinkgoBeforeAll->>TestFramework: initializeTestFramework(cfg)
        TestFramework->>TestFramework: run tests
    else kubeconfig fails
        Kubeconfig-->>CLI: cfgErr != nil
        CLI->>GinkgoBeforeAll: register BeforeAll (cfgErr!=nil)
        note right of GinkgoBeforeAll: listing/info flows allowed\nshouldIncludeTest treats ocpInfra as nil
        GinkgoBeforeAll->>GinkgoBeforeAll: panic on cfgErr/infraErr if executed
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I peeked where kubeconfigs sleep,
Nil infra makes the listings leap,
Filters pause, the spec-list sings,
But BeforeAll wakes when cluster rings,
A joyful hop — tests run or keep.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'TRT-2652: Allow OTE info and list tests commands to work without KUBECONFIG' directly describes the main change: enabling info and list tests commands to function without requiring KUBECONFIG.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@petr-muller petr-muller force-pushed the fix-info-without-kubeconfig branch from 1ae04d9 to 20254e3 Compare April 30, 2026 16:26
@petr-muller
Copy link
Copy Markdown
Member Author

/test all

@petr-muller
Copy link
Copy Markdown
Member Author

/test unit

@petr-muller petr-muller marked this pull request as ready for review May 1, 2026 17:28
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 1, 2026
@openshift-ci openshift-ci Bot requested review from kyrtapz and tssurya May 1, 2026 17:28
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openshift/cmd/ovn-kubernetes-tests-ext/main.go`:
- Around line 109-123: The current code discards the original getKubeConfig()
error and later panics with a generic "KUBECONFIG is required to run tests" in
specs.AddBeforeAll; capture and preserve the error from getKubeConfig() (e.g.,
store it in a variable like kubeCfgErr) and in the AddBeforeAll closure check
that error instead of only cfg being nil—if kubeCfgErr is non-nil, panic (or
log+panic) including the original error message so the real cause (file
unreadable, parse error, etc.) is surfaced; keep existing logic that uses cfg
when err is nil and only change the AddBeforeAll condition to reference the
preserved error variable.
🪄 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: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 3bc3919f-3584-4f1a-b0d8-a96681ad49d3

📥 Commits

Reviewing files that changed from the base of the PR and between 952886f and 20254e3.

📒 Files selected for processing (1)
  • openshift/cmd/ovn-kubernetes-tests-ext/main.go

Comment thread openshift/cmd/ovn-kubernetes-tests-ext/main.go Outdated
@petr-muller petr-muller force-pushed the fix-info-without-kubeconfig branch from 20254e3 to a0a2356 Compare May 2, 2026 00:49
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openshift/cmd/ovn-kubernetes-tests-ext/main.go`:
- Around line 109-117: Currently main() panics on ocpinfraprovider.New(cfg)
failure; change it to keep ocpInfra nil on New() error (do not panic) and only
call infraprovider.Set(...) and ocpdeploymentconfig.New() when
ocpinfraprovider.New succeeds; capture the error and store/surface it later in
AddBeforeAll alongside cfgErr so test execution (list/info) remains resilient.
Update both occurrences where ocpinfraprovider.New(cfg) is called to remove the
panic and defer error handling to AddBeforeAll, referencing getKubeConfig,
ocpinfraprovider.New, ocpInfra, infraprovider.Set, deploymentconfig.Set and
AddBeforeAll.
🪄 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: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 04a155be-245e-4bd4-a233-5789e220dbf4

📥 Commits

Reviewing files that changed from the base of the PR and between 20254e3 and a0a2356.

📒 Files selected for processing (1)
  • openshift/cmd/ovn-kubernetes-tests-ext/main.go

Comment thread openshift/cmd/ovn-kubernetes-tests-ext/main.go
Make getKubeConfig() failure non-fatal in main(). When KUBECONFIG is
absent, ocpInfra stays nil and shouldIncludeTest() includes all eligible
tests without cluster-dependent filtering (e.g. EVPN checks). The
AddBeforeAll guard ensures that running tests still requires KUBECONFIG.

This enables workflows that need to discover or list tests from
ovn-kubernetes without a live cluster connection, such as the
openshift-tests "list all-tests" command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@petr-muller petr-muller force-pushed the fix-info-without-kubeconfig branch from a0a2356 to 0e57b94 Compare May 2, 2026 18:25
@petr-muller petr-muller changed the title Allow info and list tests commands to work without KUBECONFIG TRT-2652: Allow info and list tests commands to work without KUBECONFIG May 4, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 4, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

openshift-ci-robot commented May 4, 2026

@petr-muller: This pull request references TRT-2652 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Make getKubeConfig() failure non-fatal in the ovn-kubernetes-tests-ext binary's main(). When KUBECONFIG is absent, ocpInfra stays nil and shouldIncludeTest() includes all eligible tests without cluster-dependent filtering (e.g. EVPN checks). The AddBeforeAll guard ensures that actually running tests still requires KUBECONFIG.

This enables workflows that need to discover or list tests from ovn-kubernetes without a live cluster connection, such as the openshift-tests list all-tests command being added in openshift/origin#31105.

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
  • Test discovery/listing works without a configured cluster; environment-less runs no longer apply capability-dependent filters.
  • Test execution now fails early when kubeconfig or cluster configuration is unavailable, preventing partial/invalid runs.
  • Cluster initialization is performed conditionally, avoiding unnecessary infra setup errors during list/info style operations.

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.

@petr-muller
Copy link
Copy Markdown
Member Author

petr-muller commented May 9, 2026

Before:

$ KUBECONFIG= go run ./cmd/ovn-kubernetes-tests-ext info
panic: KUBECONFIG env variable not set

goroutine 1 [running]:
main.main()
	/home/afri/Projects/RH/github.com/openshift/ovn-kubernetes/openshift/cmd/ovn-kubernetes-tests-ext/main.go:105 +0x14d9
exit status 2

$ KUBECONFIG= go run ./cmd/ovn-kubernetes-tests-ext list tests
panic: KUBECONFIG env variable not set

goroutine 1 [running]:
main.main()
	/home/afri/Projects/RH/github.com/openshift/ovn-kubernetes/openshift/cmd/ovn-kubernetes-tests-ext/main.go:105 +0x14d9
exit status 2

@petr-muller
Copy link
Copy Markdown
Member Author

After:

$ KUBECONFIG= go run ./cmd/ovn-kubernetes-tests-ext info | jq .suites[].name
"ovn-kubernetes/conformance/serial"
"ovn-kubernetes/conformance/parallel"

$ KUBECONFIG= go run ./cmd/ovn-kubernetes-tests-ext list tests | jq '.[] | .name' | head -n 5
"[Feature:NetworkSegmentation][ovn-kubernetes-ote][sig-network] Network Segmentation a user defined primary network created using NetworkAttachmentDefinitions creates a networkStatus Annotation with UDN interface L2 primary UDN [Suite:openshift/conformance/parallel]"
"[Feature:NetworkSegmentation][ovn-kubernetes-ote][sig-network] Network Segmentation a user defined primary network created using NetworkAttachmentDefinitions creates a networkStatus Annotation with UDN interface L2 primary UDN with custom network [Suite:openshift/conformance/parallel]"
"[Feature:NetworkSegmentation][ovn-kubernetes-ote][sig-network] Network Segmentation a user defined primary network created using NetworkAttachmentDefinitions creates a networkStatus Annotation with UDN interface L3 primary UDN [Suite:openshift/conformance/parallel]"
"[Feature:NetworkSegmentation][ovn-kubernetes-ote][sig-network] Network Segmentation a user defined primary network created using NetworkAttachmentDefinitions can perform east/west traffic between nodes two pods connected over a L2 primary UDN [Suite:openshift/conformance/parallel]"
"[Feature:NetworkSegmentation][ovn-kubernetes-ote][sig-network] Network Segmentation a user defined primary network created using NetworkAttachmentDefinitions can perform east/west traffic between nodes two pods connected over a L2 primary UDN with custom network [Suite:openshift/conformance/parallel]"

@petr-muller
Copy link
Copy Markdown
Member Author

Neither of the CI job failures look suspicious wrt the OTE change in this PR

@petr-muller petr-muller changed the title TRT-2652: Allow info and list tests commands to work without KUBECONFIG TRT-2652: Allow OTE info and list tests commands to work without KUBECONFIG May 9, 2026
@jluhrsen
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 10, 2026
@petr-muller
Copy link
Copy Markdown
Member Author

/assign @abhat

For approved 🙇

@petr-muller
Copy link
Copy Markdown
Member Author

Is #3170 (comment) sufficient for me to do a /verified, or does this need a networking person's involvement?

@jluhrsen
Copy link
Copy Markdown
Contributor

/verified by CI and manual testing from Petr

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label May 11, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@jluhrsen: This PR has been marked as verified by CI and manual testing from Petr.

Details

In response to this:

/verified by CI and manual testing from Petr

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.

@jluhrsen
Copy link
Copy Markdown
Contributor

/retest

@abhat
Copy link
Copy Markdown
Contributor

abhat commented May 11, 2026

/approve
@jluhrsen are we doing any fixes for the failures flagged by the security job?

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhat, jluhrsen, petr-muller

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 May 11, 2026
@jluhrsen
Copy link
Copy Markdown
Contributor

/approve @jluhrsen are we doing any fixes for the failures flagged by the security job?

no plan that I know of. we just ignore it and have been forever. I think it's failing all over openshift projects, TBH. it's because of issues in vendored code though, not ours. I tried to look at it a long time ago, and failed. just added a story to our tech dept epic about this. maybe with some help from AI I can get this cleaned up. it's always annoyed me.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 22e9487 and 2 for PR HEAD 0e57b94 in total

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

@petr-muller: 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/security 0e57b94 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.

@openshift-merge-bot openshift-merge-bot Bot merged commit a9a7b4e into openshift:master May 12, 2026
33 of 34 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.

4 participants