Repository navigation
feat(webhook): operator-managed Keycloak client credentials - #262
Conversation
c510134 to
019144b
Compare
cwiklik
left a comment
There was a problem hiding this comment.
Review Summary
Clean webhook-side implementation of the operator-managed Keycloak client credentials contract. The code correctly mounts operator-provisioned Secrets into shared-data containers, handles reinvocation for late annotations, and logs credential delivery paths. The annotation constant matches the operator PR (rossoctl/operator#247) exactly. Idempotency is well-handled throughout.
Must-fix: Made-with: Cursor trailer in 2 of 3 commits — should be Assisted-By: per kagenti conventions. Same issue flagged on the paired operator PR.
Areas reviewed: Go, Tests
Commits: 3 commits, all signed-off: yes
CI status: DCO passing
Cross-repo consistency: Annotation kagenti.io/keycloak-client-credentials-secret-name matches operator PR #247 ✓
…gistration When workloads opt out of webhook-injected client-registration, the kagenti-operator reconciler registers OAuth clients and annotates the pod template with the secret name. The mutating webhook now skips injecting the client-registration container in that case while still injecting AuthBridge sidecars, and wires the operator-provided secret for mounts. Signed-off-by: Akram <[email protected]>
- Replace operator_clientreg with keycloak_client_credentials (annotation, volume naming) - Add keycloak-client-registration logger; align deliveryPaths labels with Keycloak terminology Assisted-By: Cursor Signed-off-by: Akram <[email protected]>
Use AnnotationKeycloakClientSecretName, NeedsKeycloakClientCredentialsVolumePatch, ApplyKeycloakClientCredentialsSecretVolumes, and updated log field names. Assisted-By: Cursor Signed-off-by: Akram <[email protected]>
Signed-off-by: Akram <[email protected]>
019144b to
8a25d04
Compare
Alan-Cha
left a comment
There was a problem hiding this comment.
This PR successfully implements the webhook-side coordination for operator-managed Keycloak client registration. The code quality is excellent: idempotent, well-tested, secure (ReadOnly SubPath mounts), and provides good observability. The prior review issue (Made-with: Cursor → Assisted-By: Cursor) has been fixed ✅.
Remaining issues:
- All 4 commits and PR title are missing emoji prefixes (Kagenti convention)
- Final commit message is too generic
Prior review issues:
✅ Assisted-By: Cursor trailer fixed (was Made-with: Cursor)
Areas reviewed: Go, Tests, Security, Cross-repo consistency
Commits: 4 commits, all signed-off ✅, all missing emoji prefixes ❌
CI status: DCO passing ✅
Code quality: Excellent - idempotent, well-tested, secure mounts, good observability
|
The PR looks good to me. I will approve for now but I will do some more testing in the mean time |
|
I asked Claude to help me test a number of scenarios |
…idecar opt-in - Inject kagenti-client-registration only when kagenti.io/client-registration-inject=true - Update precedence tests and test-precedence.sh; refresh README/CLAUDE docs Signed-off-by: Akram <[email protected]>
|
Hi @Alan-Cha , thank you for the review. |
|
@akram I think we will eventually retire the sidecar client registration in favor of the operator. I'm just not sure what is the best way to do the switch. It sounds like we are doing it in this PR as well. |
sounds good |
Alan-Cha
left a comment
There was a problem hiding this comment.
Review Summary
This PR successfully implements the webhook-side coordination for operator-managed Keycloak client registration. The implementation is high quality: idempotent, well-tested, secure (ReadOnly SubPath mounts), and provides good observability through structured logging.
What this PR does:
- Mounts operator-provisioned Secrets when the annotation is present
- Handles reinvocation for late annotations (sidecars injected, then annotation appears)
- Changes client-registration from opt-out to opt-in semantics (default: operator-managed)
- Provides clear logging of credential delivery paths
Cross-repo consistency: Annotation constant kagenti.io/keycloak-client-credentials-secret-name matches operator PR rossoctl/operator#247 ✅
Previous review issues resolved:
- ✅
Assisted-By: Cursortrailer (was flagged in prior review asMade-with: Cursor, now correct)
Commits: 5 commits, all signed-off ✅
CI status: DCO passing ✅
Areas reviewed: Go, Tests, Security, Shell, Documentation
Remaining Nits (non-blocking)
All commits and the PR title are missing emoji prefixes per Kagenti conventions (see .claude/skills/git/commit.md). Examples:
- Commit 1: Should start with
✨ feat(kagenti-webhook): coordinate operator-managed... - Commit 4: Generic "Address review comments" should describe what changed
- PR title: Should be
✨ feat(webhook): operator-managed Keycloak client credentials
These are style nits that don't block merge.
Code Quality Highlights
keycloak_client_credentials.go:
- 💯 Excellent structured logging with
deliveryPathsfield makes debugging straightforward - 🔒 ReadOnly SubPath mounts are the correct security choice - prevents containers from modifying credentials
- ✅ Idempotent volume/mount application via existence checks
precedence.go:
- 👍 Clear separation of client-registration logic into
evaluateClientRegistration()with detailed comments explaining opt-in semantics
authbridge_webhook.go:
- 🎯 Excellent reinvocation handling (L626-639) catches the edge case where sidecars are injected first, then operator adds the annotation later - subtle but important
test coverage:
- ✅ Unit tests for idempotency and patching logic
- ✅ Integration test script (
test-precedence.sh) updated for new opt-in semantics - ✅ All precedence tests updated to reflect operator-managed default
Overall: This is production-ready code. Well architected, secure, and thoroughly tested. 🚀
pdettori
left a comment
There was a problem hiding this comment.
Review Summary
All prior review comments have been addressed:
- ✅
Assisted-By: Cursortrailer (wasMade-with: Cursor) - ✅ Delivery path labels shortened (
operator-secret,combined-authbridge,sidecar,skip) - ✅
V(1)for verbose admission logs - ℹ️ Emoji prefixes on commits — non-blocking nit (noted by Alan-Cha)
Commit 5 (02d61e8) adds a well-implemented behavioral change: client-registration sidecar defaults to operator-managed (not injected), with explicit kagenti.io/client-registration-inject: "true" to opt in to the legacy sidecar. The evaluateClientRegistration() function cleanly handles the 3-way decision (gate off → skip, label "true" → inject, default → operator-managed).
Code quality highlights:
- Idempotent volume/mount application with
volumeExists+appendSubPathMountguards - ReadOnly SubPath mounts — correct security choice for credential files
- Reinvocation path (
authbridge_webhook.go:626-639) correctly handles late annotation timing - Comprehensive test updates: 10+ precedence tests updated, Test 13 flipped from opt-out to opt-in, integration script updated
- Documentation updated across README, CLAUDE.md, and demo README
Cross-repo consistency: Annotation kagenti.io/keycloak-client-credentials-secret-name matches operator PR rossoctl/operator#247 ✅
Commits: 5 commits, all signed-off ✅
CI status: 12/15 passing, 3 pending (Pre-commit, CodeQL Go, Kind E2E)
Areas reviewed: Go, Tests, Security, Shell, Documentation
pdettori
left a comment
There was a problem hiding this comment.
E2E tests need updating for opt-in semantics
The Kind E2E tests are failing because tests/e2e/test_webhook_injection.py still expects kagenti-client-registration to be injected by default, but commit 5 changed it to opt-in.
Failing tests:
test_agent_pod_gets_client_registration— expects the sidecar on a plain agent pod (no opt-in label)test_agent_pod_gets_all_sidecars— includeskagenti-client-registrationin the expected set
The unit tests and test-precedence.sh were updated for the new semantics, but the Python E2E tests were missed.
Suggested fix:
test_agent_pod_gets_all_sidecars: removekagenti-client-registrationfrom the expected sidecars set (default agent pods no longer get it)test_agent_pod_gets_client_registration: either update to deploy a pod withkagenti.io/client-registration-inject: "true"and assert injection, or flip to assert it is not present by default
This is not blocked by the operator PR — it's purely a test update to match the behavioral change already in this PR. Merging with failing E2E tests would break main for other PRs.
Default agent pods no longer get kagenti-client-registration; update Kind E2E expectations, add opt-in label case, and keep opt-out checks against all possible injected sidecars. Signed-off-by: Akram <[email protected]>
|
I have fixed the e2e tests accordingly
|
Summary
Coordinates with kagenti-operator for workloads that opt out of webhook-injected client registration (
kagenti.io/client-registration-inject: "false").requires:
requires: rossoctl/operator#247
Changes
kagenti.io/keycloak-client-credentials-secret-name(volume name matches Secret:kagenti-keycloak-client-credentials-<id>).operator_clientregwithkeycloak_client_credentialshelpers:ApplyKeycloakClientCredentialsSecretVolumes,NeedsKeycloakClientCredentialsVolumePatch,AnnotationKeycloakClientSecretName.keycloak-client-registration.Related
Testing
go test ./internal/webhook/injector/...(unit); deploy webhook + operator together for integration.fixes rossoctl/rossoctl#397