feat(drift-detection): add periodic drift detection to all controllers#111
Merged
Conversation
#94) Add a DriftCheckInterval constant (5 min) and checkDrift helper methods to all 14 CRD controllers so that resources deleted externally in AxonOps are automatically detected and recreated on the next reconcile cycle. - Add DriftCheckInterval = 5 * time.Minute to common package - Extract checkDrift method per controller (returns ctrl.Result, bool, error) - Drift check fires when Ready=True, ObservedGeneration matches, and synced ID is non-empty; sets DriftDetected condition and clears synced ID on mismatch - Failed drift-check API calls set DriftCheckFailed condition and requeue - AlertEndpoint and AlertRoute resolve their own API client inside checkDrift (since apiClient is resolved after the idempotency guard in those controllers) - AdaptiveRepair, DashboardTemplate, CommitlogArchive detect drift by settings comparison or empty-list check instead of ID match - Extract applyRoute helper in AlertRoute controller to keep Reconcile cyclomatic complexity under 30 - Update LogCollector idempotency test to use stateful mock server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DriftCheckInterval = 5 * time.Minuteconstant to thecommonpackagecheckDrifthelper method to each of the 14 CRD controllerscheckDriftto verify the resource still exists externally in AxonOps before short-circuitingDriftDetectedcondition, clears the synced ID, and falls through to recreateDriftCheckFailedcondition and requeues after the drift intervalDesign notes
apiClientbefore the idempotency guard (most):checkDrifttakesapiClientas a paramapiClientafter the idempotency guard (AlertEndpoint, AlertRoute):checkDriftresolves its own client internallyapplyRoutehelper in AlertRoute to keepReconcilecyclomatic complexity ≤ 30Test plan
make lintpasses with 0 issuesmake testpasses across all packagesCloses #94