@@ -62,13 +62,11 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
6262 return fmt .Errorf ("failed to create %s: %w" , controllerName , err )
6363 }
6464
65- err = c .WatchObject (& operatorv1.Whisker {}, & handler.EnqueueRequestForObject {})
66- if err != nil {
65+ if err = c .WatchObject (& operatorv1.Whisker {}, & handler.EnqueueRequestForObject {}); err != nil {
6766 return fmt .Errorf ("%s failed to watch primary resource: %w" , controllerName , err )
6867 }
6968
70- err = c .WatchObject (& operatorv1.Goldmane {}, & handler.EnqueueRequestForObject {})
71- if err != nil {
69+ if err = c .WatchObject (& operatorv1.Goldmane {}, & handler.EnqueueRequestForObject {}); err != nil {
7270 return fmt .Errorf ("%s failed to watch for goldmane resource: %w" , controllerName , err )
7371 }
7472
@@ -102,6 +100,16 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
102100 return fmt .Errorf ("whisker-controller failed to watch Tigerastatus: %w" , err )
103101 }
104102
103+ if err = c .WatchObject (& crdv1.ClusterInformation {}, & handler.EnqueueRequestForObject {}); err != nil {
104+ return fmt .Errorf ("whisker-controller failed to watch ClusterInformation" )
105+ }
106+
107+ // Perform periodic reconciliation. This acts as a backstop to catch reconcile issues,
108+ // and also makes sure we spot when things change that might not trigger a reconciliation.
109+ if err = utils .AddPeriodicReconcile (c , utils .PeriodicReconcileTime , & handler.EnqueueRequestForObject {}); err != nil {
110+ return fmt .Errorf ("whisker-controller failed to create periodic reconcile watch: %w" , err )
111+ }
112+
105113 return nil
106114}
107115
@@ -127,7 +135,6 @@ func newReconciler(
127135// blank assignment to verify that ReconcileConnection implements reconcile.Reconciler
128136var _ reconcile.Reconciler = & Reconciler {}
129137
130- // Reconciler reconciles a ManagementClusterConnection object
131138type Reconciler struct {
132139 cli client.Client
133140 scheme * runtime.Scheme
@@ -227,7 +234,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
227234 clusterInfo := & crdv1.ClusterInformation {}
228235 err = r .cli .Get (ctx , utils .DefaultInstanceKey , clusterInfo )
229236 if err != nil {
230- reqLogger .Info ("Unable to retrieve cluster context to Whisker. Proceeding without adding cluster context to Whisker. " , err )
237+ reqLogger .Info ("Unable to retrieve ClusterInformation" , "error " , err )
231238 } else {
232239 cfg .CalicoVersion = clusterInfo .Spec .CalicoVersion
233240 cfg .ClusterType = clusterInfo .Spec .ClusterType
0 commit comments