OCPBUGS-34027: fix(hcco): clean up OIDC auth resources when external auth is removed#9017
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@hypershift-jira-solve-ci[bot]: This pull request references Jira Issue OCPBUGS-34027, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. 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. |
📝 WalkthroughWalkthroughThe OIDC reconciler now labels copied issuer CA ConfigMaps and client Secrets, tracks desired resource names, and removes stale labeled resources from Sequence Diagram(s)sequenceDiagram
participant reconcileAuthOIDC
participant HostedClusterClient
participant openshift-config
reconcileAuthOIDC->>HostedClusterClient: Read issuer CA ConfigMap and OIDC client Secrets
reconcileAuthOIDC->>openshift-config: Create or update labeled OIDC resources
reconcileAuthOIDC->>openshift-config: List labeled ConfigMaps and Secrets
reconcileAuthOIDC->>openshift-config: Delete resources absent from desired name sets
🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hypershift-jira-solve-ci[bot] The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9017 +/- ##
==========================================
+ Coverage 44.11% 44.13% +0.02%
==========================================
Files 772 772
Lines 96227 96292 +65
==========================================
+ Hits 42449 42501 +52
- Misses 50832 50839 +7
- Partials 2946 2952 +6
... and 1 file with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go (1)
1557-1561: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover transitions to hosted-cluster-sourced day-2 secrets.
Add cases that verify an old labeled HCCO copy is deleted and an existing unlabeled guest secret is preserved when this branch starts skipping the secret. The current case only verifies that no new copy is created.
As per coding guidelines, “Unit test any code changes and additions.”
🤖 Prompt for 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. In `@control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go` around lines 1557 - 1561, Extend the unit tests covering the ARO HCP and HostedClusterSourcedAnnotation branch in the secret reconciliation flow: verify that an existing HCCO-copied secret with the identifying label is deleted, while an existing guest secret without that label is preserved when reconciliation begins skipping the copy. Retain the current assertion that no new copy is created, and add coverage for both transition cases.Source: Coding guidelines
control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go (1)
2315-2315: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the required test-case description format.
Rename these cases to
When ... it should ..., for example:When OIDC providers are removed, it should clean up all labeled resources.As per coding guidelines, always use the “When ... it should ...” format when creating unit tests.
Also applies to: 2358-2358, 2397-2397, 2480-2480
🤖 Prompt for 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. In `@control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go` at line 2315, Rename the affected test-case descriptions in the resources test table to follow the required “When ... it should ...” format, including the OIDC provider removal cases and the cases at the other referenced locations. Preserve each case’s existing behavior and only update the descriptions.Source: Coding guidelines
🤖 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.
Nitpick comments:
In
`@control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go`:
- Line 2315: Rename the affected test-case descriptions in the resources test
table to follow the required “When ... it should ...” format, including the OIDC
provider removal cases and the cases at the other referenced locations. Preserve
each case’s existing behavior and only update the descriptions.
In
`@control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go`:
- Around line 1557-1561: Extend the unit tests covering the ARO HCP and
HostedClusterSourcedAnnotation branch in the secret reconciliation flow: verify
that an existing HCCO-copied secret with the identifying label is deleted, while
an existing guest secret without that label is preserved when reconciliation
begins skipping the copy. Retain the current assertion that no new copy is
created, and add coverage for both transition cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: ee285f4c-6196-4ae3-98ec-83483ee1b6c5
📒 Files selected for processing (2)
control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.gocontrol-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
|
@hypershift-jira-solve-ci[bot]: 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. |
What this PR does / why we need it:
When external OIDC authentication is removed from a HostedControlPlane (e.g. OIDCProviders cleared or auth type changed back to OAuth), the HCCO was not cleaning up the previously-created ConfigMaps and Secrets in the guest cluster's
openshift-confignamespace. This left stale OIDC resources behind.This fix adds a garbage-collection mechanism to
reconcileAuthOIDC:hypershift.openshift.io/oidc-config-resource: "true"so they can be identified as managed resources.openshift-configand deletes any that are no longer in the desired set. When OIDCProviders is empty, the desired sets are empty and all labeled resources are removed.Which issue(s) this PR fixes:
Fixes https://redhat.atlassian.net/browse/OCPBUGS-34027
Special notes for your reviewer:
reconcileAuthOIDC, comparing labeled resources against the desired set derived from the current HCP specIsNotFounderrors during deletion are safely ignored (resource may have been deleted concurrently)desiredSecrets.Insertfor ARO HCP day-2 secrets is placed before the earlycontinue, so those secrets are tracked but not copied — this prevents them from being incorrectly garbage collectedChecklist:
Always review AI generated responses prior to use.
Generated with Claude Code via openshift-developer plugin
Summary by CodeRabbit