Add webhook caching for Kanidm objects#491
Conversation
Implement a caching system for the webhook to track Kanidm objects and sync internal objects when external replication is enabled. Changes: - Add Kanidm CRD watcher to track cluster configurations - Create Kanidm client cache infrastructure for authenticated connections - Implement background task to sync internal entities (groups, persons, OAuth2 clients, service accounts) from Kanidm clusters with external replication enabled - Add entity tracking that maps entity names to their KanidmRef (cluster name and namespace) - Update validation logic to check both CRD-based objects and internally synced objects from replicated clusters - Add InternalEntityCache to track entities synced from external Kanidm clusters The webhook now prevents duplicate entity creation by checking: 1. Kubernetes CRD resources (existing behavior) 2. Internal Kanidm entities synced from clusters with external replication (new behavior) This ensures that entities replicated from external clusters cannot be accidentally recreated via CRDs, preventing conflicts in multi-cluster Kanidm deployments.
44bde81 to
ad988d6
Compare
|
@forkline could you review this PR? Don't modify it |
Code Review: Add webhook caching for Kanidm objectsOverviewThis PR implements a caching system for the webhook to track Kanidm objects and sync internal entities when external replication is enabled. The implementation prevents duplicate entity creation by checking both CRD-based objects and entities synced from external Kanidm clusters. Architecture AssessmentStrengths:
Issues & Suggestions1. Potential Resource Leak in Sync Loop (
|
|
I've reviewed PR #491 and posted a detailed code review. Summary: The PR adds webhook caching for Kanidm objects to prevent duplicate entity creation in multi-cluster deployments with external replication. The architecture is sound with proper async patterns and separation of concerns. Key issues identified:
Recommendation: Request changes for the sync loop lifecycle, error handling, and unit tests before merge. Review posted: #491 (comment) |
|
❌ Task Failed I encountered an error while trying to complete this task. If this issue persists, please check the task logs or try again. Task ID: bb7d83c5-da2d-4b52-8f45-e8b00049e688 |
|
Successfully resolved the merge conflict in PR #491. Resolution Summary:
Current PR Status:
|
Update thiserror from 2.0.17 to 2.0.18 to fix CI --locked flag error.
|
✅ CI Fix Applied Fixed. The Commit: Waiting for CI to re-run... |
…ift (#144) The basic_secret-drift runbook cited [pando85/kaniop#491](pando85/kaniop#491) as the upstream tracker, but #491 is "Add webhook caching for Kanidm objects" — unrelated to the OAuth2 secret race. Upstream search (kaniop + kanidm, open+closed issues/PRs/discussions) confirmed the multi-replica `basic_secret` read-after-write race is **not tracked upstream**. Fixed the citation to reference [#648](pando85/kaniop#648) (the `force-secret-rotation` annotation the runbook recovery relies on) and the kanidm replication eventual-consistency docs. A file-ready upstream issue for the race itself has been drafted separately (pending a decision to file). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Implement a caching system for the webhook to track Kanidm objects and sync internal objects when external replication is enabled.
Changes:
The webhook now prevents duplicate entity creation by checking:
This ensures that entities replicated from external clusters cannot be accidentally recreated via CRDs, preventing conflicts in multi-cluster Kanidm deployments.