Skip to content

CNTRLPLANE-3428: tls: introduce narrow target types and migrate test functions#31160

Open
gangwgr wants to merge 3 commits into
openshift:mainfrom
gangwgr:tls-dedup-helpers-3
Open

CNTRLPLANE-3428: tls: introduce narrow target types and migrate test functions#31160
gangwgr wants to merge 3 commits into
openshift:mainfrom
gangwgr:tls-dedup-helpers-3

Conversation

@gangwgr
Copy link
Copy Markdown
Contributor

@gangwgr gangwgr commented May 12, 2026

Introduce observedConfigTarget, configMapTarget, deploymentEnvVarTarget, serviceTarget, and deploymentRolloutTarget types, each carrying only the fields their respective test function reads.
Migrate all test function signatures and Ginkgo It loops to use the narrow types, removing the monolithic tlsTarget struct and unified targets slice.
Move HyperShift management cluster setup into a lazy setupHyperShiftManagement helper that skips tests gracefully when HYPERSHIFT_MANAGEMENT_CLUSTER_KUBECONFIG or HYPERSHIFT_MANAGEMENT_CLUSTER_NAMESPACE are not seen

Summary by CodeRabbit

  • Refactor
    • Reorganized internal test target handling and verification flows for clearer, more maintainable test logic; no user-facing changes.
  • Tests
    • Streamlined and optimized test iterations, disruptive-flow verifications, and cleanup patterns by precomputing focused target lists—improves test reliability and performance without altering test outcomes.

@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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Refactors tests in test/extended/tls/tls_observed_config.go to replace a single generic tlsTarget with five narrow typed targets and precomputed typed target lists; updates test loops, helpers, HyperShift flows, and wait logic to use these typed lists and explicit rollout targets.

Changes

TLS verification target refactor (single cohesive cohort)

Layer / File(s) Summary
Typed target structs & precomputed lists
test/extended/tls/tls_observed_config.go (lines 46–207)
Add observedConfigTarget, configMapTarget, deploymentEnvVarTarget, serviceTarget, deploymentRolloutTarget and global typed slices. Implement guest-side subset helpers that compute non-control-plane typed guest lists once during setup.
Read-only verification loops
test/extended/tls/tls_observed_config.go (lines 230–267)
Replace iterations over the unified targets with loops over observedConfigTargets, configMapTargets, deploymentEnvVarTargets, and serviceTargets for ObservedConfig, ConfigMap injection, deployment env-var, and wire-level TLS checks.
HyperShift setup and disruptive flows
test/extended/tls/tls_observed_config.go (lines 285–369, 386–430, 576–613)
Make HyperShift management setup explicit via setupHyperShiftManagement(). Precompute guest typed target subsets, update Modern and Custom disruptive flows to use those guest lists, pass guestRollouts []deploymentRolloutTarget into waitForGuestOperatorsAfterTLSChange, and use typed guest lists for verification and DeferCleanup.
Standalone Modern/Custom flows
test/extended/tls/tls_observed_config.go (lines 490–542, 688–730)
Update standalone OCP Modern/Custom verification loops to iterate deploymentEnvVarTargets, configMapTargets, and serviceTargets instead of the unified targets.
Helper signatures & verification helpers
test/extended/tls/tls_observed_config.go (lines 748–1215, 1258–1303, 1448–1460)
Change test/helper signatures to accept narrow target types (e.g., testObservedConfig(observedConfigTarget), testConfigMapTLSInjection(configMapTarget), testDeploymentTLSEnvVars(deploymentEnvVarTarget), testWireLevelTLS(serviceTarget)). Introduce typed verifier helpers (verifyObservedConfigForTargets, verifyConfigMapsForTargets) and update checkTLSConnection to accept serviceTarget.
Stabilization and operator/deployment wait logic
test/extended/tls/tls_observed_config.go (lines 1318–1322, 1644–1652, 1758–1769)
Remove helpers that derived operator/deployment names from the unified targets. Use predeclared clusterOperatorNames and deploymentRolloutTargets. Update waitForAllOperatorsAfterTLSChange and waitForGuestOperatorsAfterTLSChange to iterate predeclared/explicit rollout targets.
Imports & cleanup
test/extended/tls/tls_observed_config.go (top)
Add os import, remove obsolete helper functions that derived guest/operator lists from the unified targets, and clean up related unused code.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels: lgtm


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Stable And Deterministic Test Names ❌ Error 8 Ginkgo It() calls use fmt.Sprintf to dynamically inject namespace and port values into test titles, violating the requirement for stable, deterministic test names. Replace fmt.Sprintf-based test names with static descriptions. Move namespace/port details to test body assertions instead of test titles.
Test Structure And Quality ⚠️ Warning 72% of assertions (61/85) lack meaningful failure messages per requirement #4, contradicting best practices shown in codebase samples. Add context message parameters to ~61 bare Expect statements. Ensure consistent assertion messages across all test functions for better diagnostics.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing narrow target types and migrating test functions in the TLS test file, which directly matches the refactoring described in the raw summary.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
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.
Microshift Test Compatibility ✅ Passed All 10 new tests protected from MicroShift via exutil.IsMicroShiftCluster() + g.Skip() in BeforeEach blocks, following Option 3 from guidelines.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Tests verify TLS config via observedConfig, ConfigMaps, env vars, and port-forward. No multi-node assumptions. Work on SNO with single-replica deployments. Already skip MicroShift.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies test file only (test/extended/tls/tls_observed_config.go), not deployment manifests or operator code. No scheduling constraints introduced. Check is not applicable to test infrastructure.
Ote Binary Stdout Contract ✅ Passed The file uses only e2e.Logf for logging (safe - goes to GinkgoWriter), fmt.Sprintf/fmt.Errorf for formatting, and no main/TestMain/init functions. No stdout contract violations found.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR refactors existing tests, not adding new. Tests handle IPv4/IPv6 gracefully: checkTLSConnection() tests both 127.0.0.1 and [::1], skips unavailable addresses, fails only if both unavailable.
✨ 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 openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 12, 2026
@gangwgr gangwgr changed the title tls: introduce narrow target types and migrate test functions CNTRLPLANE-3428: tls: introduce narrow target types and migrate test functions May 12, 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 12, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 12, 2026

@gangwgr: This pull request references CNTRLPLANE-3428 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:

Introduce observedConfigTarget, configMapTarget, deploymentEnvVarTarget, serviceTarget, and deploymentRolloutTarget types, each carrying only the fields their respective test function reads.
Migrate all test function signatures and Ginkgo It loops to use the narrow types, removing the monolithic tlsTarget struct and unified targets slice.
Move HyperShift management cluster setup into a lazy setupHyperShiftManagement helper that skips tests gracefully when HYPERSHIFT_MANAGEMENT_CLUSTER_KUBECONFIG or HYPERSHIFT_MANAGEMENT_CLUSTER_NAMESPACE are not seen

Summary by CodeRabbit

  • Refactor
  • Updated internal test infrastructure for improved code organization and maintainability. No user-facing changes.

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
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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended/tls/tls_observed_config.go`:
- Around line 109-118: configMapTargets is missing controlPlane: true on several
control-plane entries which makes guestSideConfigMapTargets() incorrectly
include ConfigMaps for HyperShift guests; update the configMapTargets slice to
add controlPlane: true to the entries for "openshift-controller-manager",
"openshift-kube-apiserver" (kube-apiserver-operator-config),
"openshift-apiserver", "openshift-kube-controller-manager", and
"openshift-kube-scheduler" so it matches observedConfigTargets/serviceTargets
and prevents guest-side verification against non-existent guest ConfigMaps.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 95cfc937-791b-4fb6-9740-ad634597701c

📥 Commits

Reviewing files that changed from the base of the PR and between 16bf93d and 3a8ee7c.

📒 Files selected for processing (1)
  • test/extended/tls/tls_observed_config.go

Comment thread test/extended/tls/tls_observed_config.go
@openshift-merge-bot openshift-merge-bot Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label May 12, 2026
@gangwgr gangwgr force-pushed the tls-dedup-helpers-3 branch from 40203f2 to a015595 Compare May 12, 2026 07:07
@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

@gangwgr gangwgr force-pushed the tls-dedup-helpers-3 branch 2 times, most recently from 17f6ed3 to 4034867 Compare May 12, 2026 11:28
@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

@ingvagabund
Copy link
Copy Markdown
Member

tls: migrate to narrow target types and skip HyperShift gracefully commit has still too many unrelated changes in it. Please divide it into more commits.

@gangwgr gangwgr force-pushed the tls-dedup-helpers-3 branch 2 times, most recently from 2763ef2 to fe8c1ed Compare May 13, 2026 13:30
@gangwgr
Copy link
Copy Markdown
Contributor Author

gangwgr commented May 14, 2026

/test verify

// running on a HyperShift guest cluster.
// Pre-compute guest-side target lists so the filter functions are
// called once rather than on every config-change verification.
guestObservedCfg := guestSideObservedConfigTargets()
Copy link
Copy Markdown
Member

@ingvagabund ingvagabund May 15, 2026

Choose a reason for hiding this comment

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

How is this change related to "tls: skip HyperShift management setup gracefully"?

This change (and other lines below) belongs more under "tls: migrate to narrow target types" commit (where the functions are defined).

Also, it might be even more transparent to move it under a separate commit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated

@gangwgr gangwgr force-pushed the tls-dedup-helpers-3 branch from fe8c1ed to 5cd1345 Compare May 15, 2026 10:56
Replace the monolithic tlsTarget struct and targets slice with
purpose-specific narrow types (observedConfigTarget, configMapTarget,
deploymentEnvVarTarget, serviceTarget, deploymentRolloutTarget).

Each test loop now iterates over its own typed slice, removing the
field-presence checks that previously filtered the unified list.
Function signatures are updated to accept the narrow types, making
data dependencies explicit at the call site.

Old helper functions (targetClusterOperators, guestSideTargets,
guestSideClusterOperators) are replaced by the pre-built
clusterOperatorNames slice and typed guestSide*() filter functions.
Guest-side target lists are pre-computed once at Describe level.
@gangwgr gangwgr force-pushed the tls-dedup-helpers-3 branch from 5cd1345 to 7e184e8 Compare May 15, 2026 11:01

setupHyperShiftManagement := func() {
if os.Getenv("HYPERSHIFT_MANAGEMENT_CLUSTER_KUBECONFIG") == "" || os.Getenv("HYPERSHIFT_MANAGEMENT_CLUSTER_NAMESPACE") == "" {
g.Skip("HYPERSHIFT_MANAGEMENT_CLUSTER_KUBECONFIG and HYPERSHIFT_MANAGEMENT_CLUSTER_NAMESPACE must be set for config-change tests on HyperShift")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should not this fail instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it should skip only

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The message says "must be set" which gives the impression it is required when setupHyperShiftManagement is invoked. In which test cases are both envs expected to be set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated

@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

@gangwgr
Copy link
Copy Markdown
Contributor Author

gangwgr commented May 15, 2026

/retest-required

Defer HyperShift management-cluster initialization to the individual
config-change tests that actually need it, instead of running it
unconditionally in BeforeEach. Tests that only read guest-cluster
state (annotation restoration, servingInfo restoration) no longer
require HYPERSHIFT_MANAGEMENT_CLUSTER_KUBECONFIG to be set.

The new setupHyperShiftManagement() helper checks for the required
env vars and calls g.Skip when they are absent, so config-change
tests are skipped cleanly rather than failing with a hard error.
@gangwgr gangwgr force-pushed the tls-dedup-helpers-3 branch from 7e184e8 to 9e326b3 Compare May 15, 2026 16:08
@ingvagabund
Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 15, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 15, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gangwgr, ingvagabund

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-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

@gangwgr
Copy link
Copy Markdown
Contributor Author

gangwgr commented May 15, 2026

/test e2e-metal-ipi-ovn-ipv6

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 15, 2026

@gangwgr: The following tests 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-metal-ipi-ovn-ipv6 9e326b3 link true /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-aws-csi 9e326b3 link true /test e2e-aws-csi

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-trt
Copy link
Copy Markdown

openshift-trt Bot commented May 15, 2026

Job Failure Risk Analysis for sha: 9e326b3

Job Name Failure Risk
pull-ci-openshift-origin-main-e2e-metal-ipi-ovn-ipv6 IncompleteTests
Tests for this run (20) are below the historical average (3412): IncompleteTests (not enough tests ran to make a reasonable risk analysis; this could be due to infra, installation, or upgrade problems)

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. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants