CNTRLPLANE-3428: tls: extract annotation and ConfigMap update helpers#31156
Conversation
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.
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
|
@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. DetailsIn response to this:
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughExtracts three reusable test helpers— ChangesConfigMap annotation restoration helpers and test updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 11 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
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.
|
Scheduling required tests: |
|
/lgtm |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/verfied by @gangwgr |
|
/verified by @gangwgr |
|
@gangwgr: This PR has been marked as verified by DetailsIn response to this:
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. |
|
@gangwgr: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
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