From cd11edc7ec4cc04c2ff18710bc44e99326291612 Mon Sep 17 00:00:00 2001 From: Christopher Dziomba Date: Fri, 15 Nov 2024 09:45:28 +0100 Subject: [PATCH 1/2] Always trigger one initial reconciliation --- cmd/manager/main.go | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index c97a1c3..b05345d 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -167,12 +167,6 @@ func main() { } func initComponents(mgr manager.Manager, anycastTracker *anycast.Tracker, cfg *config.Config, clientConfig *rest.Config, onlyBPFMode bool) error { - // Start VRFRouteConfigurationReconciler when we are not running in only BPF mode. - if !onlyBPFMode { - if err := setupReconcilers(mgr, anycastTracker); err != nil { - return fmt.Errorf("unable to setup reconcilers: %w", err) - } - } //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { @@ -223,18 +217,25 @@ func initComponents(mgr manager.Manager, anycastTracker *anycast.Tracker, cfg *c if err = performNetworkingHealthcheck(hc); err != nil { return fmt.Errorf("error performing healthcheck: %w", err) } + } else { + // Start VRFRouteConfigurationReconciler when we are not running in only BPF mode. + r, err := reconciler.NewReconciler(mgr.GetClient(), anycastTracker, mgr.GetLogger()) + if err != nil { + return fmt.Errorf("unable to create debounced reconciler: %w", err) + } + if err := setupReconcilers(r, mgr, anycastTracker); err != nil { + return fmt.Errorf("unable to setup reconcilers: %w", err) + } + + // Trigger initial reconciliation. + r.Reconcile(context.Background()) } return nil } -func setupReconcilers(mgr manager.Manager, anycastTracker *anycast.Tracker) error { - r, err := reconciler.NewReconciler(mgr.GetClient(), anycastTracker, mgr.GetLogger()) - if err != nil { - return fmt.Errorf("unable to create debounced reconciler: %w", err) - } - - if err = (&controllers.VRFRouteConfigurationReconciler{ +func setupReconcilers(r *reconciler.Reconciler, mgr manager.Manager, anycastTracker *anycast.Tracker) error { + if err := (&controllers.VRFRouteConfigurationReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), Reconciler: r, @@ -242,7 +243,7 @@ func setupReconcilers(mgr manager.Manager, anycastTracker *anycast.Tracker) erro return fmt.Errorf("unable to create VRFRouteConfiguration controller: %w", err) } - if err = (&controllers.Layer2NetworkConfigurationReconciler{ + if err := (&controllers.Layer2NetworkConfigurationReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), Reconciler: r, @@ -250,7 +251,7 @@ func setupReconcilers(mgr manager.Manager, anycastTracker *anycast.Tracker) erro return fmt.Errorf("unable to create Layer2NetworkConfiguration controller: %w", err) } - if err = (&controllers.RoutingTableReconciler{ + if err := (&controllers.RoutingTableReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), Reconciler: r, From db7706100b31011c145405fbe06d2076f3a733ba Mon Sep 17 00:00:00 2001 From: Christopher Dziomba Date: Fri, 15 Nov 2024 10:00:47 +0100 Subject: [PATCH 2/2] remove not-needed parameter --- cmd/manager/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index b05345d..06d5788 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -223,7 +223,7 @@ func initComponents(mgr manager.Manager, anycastTracker *anycast.Tracker, cfg *c if err != nil { return fmt.Errorf("unable to create debounced reconciler: %w", err) } - if err := setupReconcilers(r, mgr, anycastTracker); err != nil { + if err := setupReconcilers(r, mgr); err != nil { return fmt.Errorf("unable to setup reconcilers: %w", err) } @@ -234,7 +234,7 @@ func initComponents(mgr manager.Manager, anycastTracker *anycast.Tracker, cfg *c return nil } -func setupReconcilers(r *reconciler.Reconciler, mgr manager.Manager, anycastTracker *anycast.Tracker) error { +func setupReconcilers(r *reconciler.Reconciler, mgr manager.Manager) error { if err := (&controllers.VRFRouteConfigurationReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(),