Skip to content

CNTRLPLANE-3428: tls: extract annotation and ConfigMap update helpers#31156

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift:mainfrom
gangwgr:tls-dedup-helpers-2
May 11, 2026
Merged

CNTRLPLANE-3428: tls: extract annotation and ConfigMap update helpers#31156
openshift-merge-bot[bot] merged 4 commits into
openshift:mainfrom
gangwgr:tls-dedup-helpers-2

Conversation

@gangwgr
Copy link
Copy Markdown
Contributor

@gangwgr gangwgr commented May 11, 2026

Extract requireAnnotation helper to deduplicate annotation-existence checks across testAnnotationRestorationAfterDeletion and testAnnotationRestorationWhenFalse.
Extract updateConfigMap helper to deduplicate inline ConfigMap update calls across 4 test functions (testAnnotationRestorationAfterDeletion, testAnnotationRestorationWhenFalse, testServingInfoRestorationAfterRemoval, testServingInfoRestorationAfterModification).
Extract waitForAnnotation helper to deduplicate polling-for-annotation-restoration logic across testAnnotationRestorationAfterDeletion and testAnnotationRestorationWhenFalse.
This is the third PR in a series refactoring test/extended/tls to reduce duplication and improve readability. Previous PRs:

#31077 — extracted injectTLSAnnotation constant
#31136 — removed defaulting logic and extracted validateNamespace + getConfigMap helpers

Summary by CodeRabbit

  • Tests
    • Refactored TLS configuration tests to use shared helpers, reducing duplication and improving readability.
    • Standardized update and polling logic across deletion and modification test paths for more consistent, reliable test behavior.

gangwgr added 3 commits May 11, 2026 19:13
Add a reusable requireAnnotation function that asserts a given
annotation key is present on a ConfigMap and update
testAnnotationRestorationAfterDeletion and
testAnnotationRestorationWhenFalse to use it.
Add a reusable updateConfigMap function that writes a ConfigMap
back to the API server (reading namespace from the object itself)
and update testAnnotationRestorationAfterDeletion,
testAnnotationRestorationWhenFalse,
testServingInfoRestorationAfterRemoval, and
testServingInfoRestorationAfterModification to use it.
Add a reusable waitForAnnotation function that polls until a
given annotation reaches an expected value and update
testAnnotationRestorationAfterDeletion and
testAnnotationRestorationWhenFalse to use it.

The function accepts annotationKey and annotationValue as
arguments so it can be reused for any annotation.
@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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 11, 2026
@gangwgr gangwgr changed the title tls: extract annotation and ConfigMap update helpers CNTRLPLANE-3428: tls: extract annotation and ConfigMap update helpers May 11, 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 11, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 11, 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:

Extract requireAnnotation helper to deduplicate annotation-existence checks across testAnnotationRestorationAfterDeletion and testAnnotationRestorationWhenFalse.
Extract updateConfigMap helper to deduplicate inline ConfigMap update calls across 4 test functions (testAnnotationRestorationAfterDeletion, testAnnotationRestorationWhenFalse, testServingInfoRestorationAfterRemoval, testServingInfoRestorationAfterModification).
Extract waitForAnnotation helper to deduplicate polling-for-annotation-restoration logic across testAnnotationRestorationAfterDeletion and testAnnotationRestorationWhenFalse.
This is the third PR in a series refactoring test/extended/tls to reduce duplication and improve readability. Previous PRs:

#31077 — extracted injectTLSAnnotation constant
#31136 — removed defaulting logic and extracted validateNamespace + getConfigMap helpers

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9d7ca276-ea32-4392-932b-44d1a8337e58

📥 Commits

Reviewing files that changed from the base of the PR and between b0711d2 and 5685048.

📒 Files selected for processing (1)
  • test/extended/tls/tls_observed_config.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/extended/tls/tls_observed_config.go

Walkthrough

Extracts three reusable test helpers—requireAnnotation, updateConfigMap, and waitForAnnotation—and replaces duplicated ConfigMap update/assert/poll logic in four TLS ConfigMap restoration tests with these helpers.

Changes

ConfigMap annotation restoration helpers and test updates

Layer / File(s) Summary
Helper Functions
test/extended/tls/tls_observed_config.go (lines 1016–1063)
Adds requireAnnotation (asserts annotation exists), updateConfigMap (conflict-retrying ConfigMap update), and waitForAnnotation (polls until annotation equals expected value).
Deletion-based annotation test
test/extended/tls/tls_observed_config.go (lines 1147–1155)
testAnnotationRestorationAfterDeletion now uses requireAnnotation, updateConfigMap, and waitForAnnotation instead of inline update + manual polling.
False-annotation test
test/extended/tls/tls_observed_config.go (lines 1167–1174)
testAnnotationRestorationWhenFalse refactored to use the three helpers in place of embedded polling and direct updates.
ServingInfo removal test
test/extended/tls/tls_observed_config.go (lines 1231–1236)
testServingInfoRestorationAfterRemoval now calls updateConfigMap when writing back the modified ConfigMap (poll/verification unchanged).
ServingInfo modification test
test/extended/tls/tls_observed_config.go (lines 1305–1310)
testServingInfoRestorationAfterModification now calls updateConfigMap when writing back the modified ConfigMap (poll/verification unchanged).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Test Structure And Quality ❓ Inconclusive No result was produced after verification. Marking as INCONCLUSIVE. Re-run the check or adjust instructions to produce a final result.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: extracting helper functions (requireAnnotation, updateConfigMap, waitForAnnotation) to reduce code duplication in TLS-related tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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.
Stable And Deterministic Test Names ✅ Passed Test titles use static strings or hardcoded targets list values. Namespace and port values are static OpenShift identifiers without random suffixes, ensuring deterministic test names.
Microshift Test Compatibility ✅ Passed No new Ginkgo tests are added in this PR—only existing test functions are refactored with helper extraction. MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests are being added. PR is a refactoring that extracts helper functions from existing tests. Custom check applies only to new tests being added.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies test code only, extracting helper functions. No deployment manifests, operator code, or controllers changed. No scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed PR extracts three test helper functions using proper logging mechanisms (e2e.Logf, g.By, fmt.Sprintf). All helpers are called only from test blocks. No process-level stdout writes detected.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR refactors existing test helpers; no new Ginkgo test cases are added. The check applies only to new tests being added, not to refactoring of existing code.

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

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

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

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 1024-1028: The updateConfigMap function currently does a single
oc.AdminKubeClient().CoreV1().ConfigMaps(cm.Namespace).Update(...) which can
return 409 Conflict during controller reconciliation; wrap the Update call in
retry.RetryOnConflict(retry.DefaultRetry, func() error { ... }) and inside the
closure re-fetch the ConfigMap if needed (or use the passed cm) and call Update,
returning the error to let the retry handle conflicts; ensure the final error is
asserted with o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("failed to
update ConfigMap %s/%s", cm.Namespace, cm.Name)).
🪄 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: 8635b19d-d08f-4192-aaba-0edace386892

📥 Commits

Reviewing files that changed from the base of the PR and between 5ab531b and b0711d2.

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

Comment thread test/extended/tls/tls_observed_config.go
Wrap the ConfigMap update in retry.RetryOnConflict to handle
409 Conflict errors that can occur when controllers reconcile
the same ConfigMap concurrently, preventing test flakes.
@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 11, 2026
@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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 11, 2026
@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: 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

@gangwgr
Copy link
Copy Markdown
Contributor Author

gangwgr commented May 11, 2026

/verfied by @gangwgr

@gangwgr
Copy link
Copy Markdown
Contributor Author

gangwgr commented May 11, 2026

/verified by @gangwgr

@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

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

Details

In response to this:

/verified by @gangwgr

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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 11, 2026

@gangwgr: all tests passed!

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 bd272cd into openshift:main May 11, 2026
21 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. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review 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