controller/orgunit: reconciler for hold-period expiry and hard-delete (#182)#188
Conversation
…go-core-stack#182) Implements a reconciler controller using core/reconciler to handle hold-period expiry and hard-delete of soft-deleted org-units. Changes: - pkg/controller/orgunit/reconciler.go: OrgUnitReconciler that computes holdExpiry = deleted + hold_deleted_ou, requeues if not yet expired, hard-deletes via DeleteKey when hold period expires - pkg/table/org-unit.go: ReconcilerGetAllKeys override returns only keys where deleted > 0 (soft-deleted entries pending hard-delete), adds Deleted field to OrgUnitEntry - main.go: conditional startup — reconciler only registers when experimental.allow_ou_delete is true, threads ExperimentalConfig
WalkthroughAdds soft-delete support to Org-unit cleanup reconciler
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@main.go`:
- Line 589: The call to NewOrgUnitServer in main.go is out of sync with the
constructor signature in pkg/server/org-unit.go, so the build will fail. Update
NewOrgUnitServer and its implementation to accept the experimental config
argument consistently, and make sure any call sites, the serverCtx setup, and
the org-unit server constructor logic all use the same parameter list.
In `@pkg/controller/orgunit/reconciler.go`:
- Line 71: The OrgUnitCleanupController constructor is using an undefined
config.ExperimentalConfig type, so update NewOrgUnitCleanupController to accept
the actual exported experimental config type returned by conf.GetExperimental()
or change the config package to export the intended type. Make the signature and
any related references in orgunit/reconciler.go use the same concrete type so
golangci-lint and compilation succeed.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 55c16920-952d-46d8-be98-a1191a1e6d26
📒 Files selected for processing (3)
main.gopkg/controller/orgunit/reconciler.gopkg/table/org-unit.go
Summary
Implements a reconciler controller using
go-core-stack/core/reconcilerto handle hold-period expiry and hard-delete of soft-deleted org-units (issue #182).Changes:
pkg/controller/orgunit/reconciler.go: NewOrgUnitCleanupControllerwithorgUnitReconcilerthat:holdExpiry = deleted + hold_deleted_ouholdExpiry > now: returnsResult{RequeueAfter: remaining + 1s}for delayed re-enqueueholdExpiry <= now: hard-deletes the entry viaDeleteKey, returns nilpkg/table/org-unit.go:ReconcilerGetAllKeys()override onOrgUnitTablereturns only keys wheredeleted > 0— ensures the reconciler bootstraps only entries pending hard-delete (not all org-units)main.go: Conditional startup — reconciler only registers whenexperimental.allow_ou_deleteistrueDesign:
EmailVerificationCleanupController, tenant controllers)core/reconcilerpipeline for dedup, error retry, andRequeueAfter-based delayed processingReconcilerGetAllKeys()bootstraps all existing soft-deleted entries — handles process restart recoveryNotifyCallbackfrom MongoDB change stream picks up new soft-deletes automaticallyorg-unit-users— that is a separate concern per the issueTest plan
allow_ou_delete: truein confighold_deleted_ousecondsReconcilerGetAllKeysCloses #182
Summary by CodeRabbit
New Features
Bug Fixes