fix: watch Secrets to clear transient APIKey failures#82
Conversation
The APIKey status controller sets SecretNotFound when the referenced Secret does not exist yet. However, no watched resource changes when the Secret is subsequently created, so the APIKey stays stuck in Failed state permanently. Add a Secret watch so creation/updates trigger re-reconciliation. The existing calculateFailedCondition logic already re-evaluates and clears the failure when the Secret appears. Fixes #78 Signed-off-by: Thomas Maas <thomas@webtypes.com>
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe APIKey status controller now has permission to read Kubernetes Secrets and watches Secret resources, enqueueing APIKey status reconciliation when Secrets change. ChangesAPIKey Secret reconciliation
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Verify that an APIKey in SecretNotFound state recovers when the referenced Secret is subsequently created. This is the scenario triggered by the console-plugin's ownerReference flow (PR #541) where the APIKey is created before its Secret. Ref #78 Signed-off-by: Thomas Maas <thomas@webtypes.com>
Summary
The APIKey status controller sets
SecretNotFoundwhen the referenced Secret doesn't exist yet. But no watched resource changes when the Secret is subsequently created, so the APIKey stays stuck inFailedstate permanently.Adding a Secret watch triggers re-reconciliation when Secrets are created/updated. The existing
calculateFailedConditionlogic already re-evaluates and clears the failure when the Secret appears — no additional status logic needed.Changes
internal/controller/apikey_status_controller.go: addWatches(&corev1.Secret{}, ...)toSetupWithManager, update RBAC marker to includelist;watchapikey_secret_controlleralready grantslist;watchon SecretsContext
This unblocks kuadrant-console-plugin#541, which reorders APIKey/Secret creation to set ownerReferences for garbage collection. The new create order (APIKey first, then Secret) triggers this bug.
Fixes #78
Summary by CodeRabbit