Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/controller/goldmane/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
return fmt.Errorf("failed to create %s: %w", controllerName, err)
}

err = c.WatchObject(&operatorv1.Goldmane{}, &handler.EnqueueRequestForObject{})
if err != nil {
if err = c.WatchObject(&operatorv1.Goldmane{}, &handler.EnqueueRequestForObject{}); err != nil {
return fmt.Errorf("%s failed to watch primary resource: %w", controllerName, err)
}

Expand All @@ -81,8 +80,7 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
return fmt.Errorf("failed to add watch for config map %s/%s: %w", common.OperatorNamespace(), certificatemanagement.TrustedCertConfigMapName, err)
}

err = c.WatchObject(&operatorv1.ManagementClusterConnection{}, &handler.EnqueueRequestForObject{})
if err != nil {
if err = c.WatchObject(&operatorv1.ManagementClusterConnection{}, &handler.EnqueueRequestForObject{}); err != nil {
return fmt.Errorf("%s failed to watch management cluster connection resource: %w", controllerName, err)
}

Expand All @@ -102,6 +100,12 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
return fmt.Errorf("goldmane-controller failed to watch Tigerastatus: %w", err)
}

// Perform periodic reconciliation. This acts as a backstop to catch reconcile issues,
// and also makes sure we spot when things change that might not trigger a reconciliation.
if err = utils.AddPeriodicReconcile(c, utils.PeriodicReconcileTime, &handler.EnqueueRequestForObject{}); err != nil {
return fmt.Errorf("goldmane-controller failed to create periodic reconcile watch: %w", err)
}

return nil
}

Expand Down
19 changes: 13 additions & 6 deletions pkg/controller/whisker/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
return fmt.Errorf("failed to create %s: %w", controllerName, err)
}

err = c.WatchObject(&operatorv1.Whisker{}, &handler.EnqueueRequestForObject{})
if err != nil {
if err = c.WatchObject(&operatorv1.Whisker{}, &handler.EnqueueRequestForObject{}); err != nil {
return fmt.Errorf("%s failed to watch primary resource: %w", controllerName, err)
}

err = c.WatchObject(&operatorv1.Goldmane{}, &handler.EnqueueRequestForObject{})
if err != nil {
if err = c.WatchObject(&operatorv1.Goldmane{}, &handler.EnqueueRequestForObject{}); err != nil {
return fmt.Errorf("%s failed to watch for goldmane resource: %w", controllerName, err)
}

Expand Down Expand Up @@ -102,6 +100,16 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
return fmt.Errorf("whisker-controller failed to watch Tigerastatus: %w", err)
}

if err = c.WatchObject(&crdv1.ClusterInformation{}, &handler.EnqueueRequestForObject{}); err != nil {
return fmt.Errorf("whisker-controller failed to watch ClusterInformation")
}

// Perform periodic reconciliation. This acts as a backstop to catch reconcile issues,
// and also makes sure we spot when things change that might not trigger a reconciliation.
if err = utils.AddPeriodicReconcile(c, utils.PeriodicReconcileTime, &handler.EnqueueRequestForObject{}); err != nil {
return fmt.Errorf("whisker-controller failed to create periodic reconcile watch: %w", err)
}

return nil
}

Expand All @@ -127,7 +135,6 @@ func newReconciler(
// blank assignment to verify that ReconcileConnection implements reconcile.Reconciler
var _ reconcile.Reconciler = &Reconciler{}

// Reconciler reconciles a ManagementClusterConnection object
type Reconciler struct {
cli client.Client
scheme *runtime.Scheme
Expand Down Expand Up @@ -227,7 +234,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
clusterInfo := &crdv1.ClusterInformation{}
err = r.cli.Get(ctx, utils.DefaultInstanceKey, clusterInfo)
if err != nil {
reqLogger.Info("Unable to retrieve cluster context to Whisker. Proceeding without adding cluster context to Whisker.", err)
reqLogger.Info("Unable to retrieve ClusterInformation", "error", err)
} else {
cfg.CalicoVersion = clusterInfo.Spec.CalicoVersion
cfg.ClusterType = clusterInfo.Spec.ClusterType
Expand Down