Refactor controller reconcile signatures and add event-driven watches#300
Open
felix-kaestner wants to merge 1 commit intodevicefrom
Open
Refactor controller reconcile signatures and add event-driven watches#300felix-kaestner wants to merge 1 commit intodevicefrom
felix-kaestner wants to merge 1 commit intodevicefrom
Conversation
798f544 to
05733fa
Compare
8faf1be to
ed93b40
Compare
05733fa to
0435441
Compare
Consistently apply the following patterns across all controllers: - Change reconcile() return type from (ctrl.Result, error) to (error). Move the RequeueAfter result to the Reconcile() caller so reconcile() is only responsible for business logic, not requeue scheduling. - Remove the RequeueInterval field from ISIS, PIM, and VRF reconcilers (and the corresponding validation in SetupWithManager and wiring in cmd/main.go). These controllers now use proper watch triggers to reconcile based on referenced resource changes. Unlike controllers that track operational state (e.g. interface oper-status), these resources have no device-side operational state requiring periodic syncs. - Remove cached references from scope structs (e.g. Interfaces, VRF, PeerLink in lldpScope, dhcprelayScope, vpcdomainScope). Previously these fields were fetched and set in sub-reconciler functions, then read back in reconcile() through the scope. This pattern should be avoided because: 1) the values never leave the reconcile() function scope and 2) they are absent from the scope when passed to finalize(), where a reader might assume they are populated. Use local variables within reconcile() instead. - Add Interface Watches to ISIS, OSPF, and PIM controllers that trigger reconciliation when a referenced Interface's Configured condition changes, replacing the previous poll-based requeue. - Align vpcdomain_controller with the rest of the codebase: rename import aliases (nxv1 to nxv1alpha1, corev1 to unaliased v1alpha1), replace meta.FindStatusCondition with conditions.Get in watch predicates, extract field indexer key strings into package-level constants, and remove the now unused conditionChanged helper. - Add kubebuilder default markers and a Reset() method to VPCDomainStatus instead of having a method on the reconciler.
0435441 to
bc6b6f2
Compare
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.
Consistently apply the following patterns across all controllers:
Change reconcile() return type from (ctrl.Result, error) to (error). Move the RequeueAfter result to the Reconcile() caller so reconcile() is only responsible for business logic, not requeue scheduling.
Remove the RequeueInterval field from ISIS, PIM, and VRF reconcilers (and the corresponding validation in SetupWithManager and wiring in cmd/main.go). These controllers now use proper watch triggers to reconcile based on referenced resource changes. Unlike controllers that track operational state (e.g. interface oper-status), these resources have no device-side operational state requiring periodic syncs.
Remove cached references from scope structs (e.g. Interfaces, VRF, PeerLink in lldpScope, dhcprelayScope, vpcdomainScope). Previously these fields were fetched and set in sub-reconciler functions, then read back in reconcile() through the scope. This is a poor pattern because: 1) the values never leave the reconcile() function scope and 2) they are absent from the scope when passed to finalize(), where a reader might assume they are populated. Use local variables within reconcile() instead.
Add Interface Watches to ISIS, OSPF, and PIM controllers that trigger reconciliation when a referenced Interface's Configured condition changes, replacing the previous poll-based requeue.
Align vpcdomain_controller with the rest of the codebase: rename import aliases (nxv1 to nxv1alpha1, corev1 to unaliased v1alpha1), replace meta.FindStatusCondition with conditions.Get in watch predicates, extract field indexer key strings into package-level constants, and remove the now unused conditionChanged helper.
Add kubebuilder default markers and a Reset() method to VPCDomainStatus instead of having a method on the reconciler.