From b4db11af394524631ee961d7e6d343445924f4b5 Mon Sep 17 00:00:00 2001 From: Priyank Upadhyay Date: Tue, 2 Apr 2024 12:04:44 +0530 Subject: [PATCH] fix(): Refactor cluster reconciliation and update CNI subnet configuration Signed-off-by: Priyank Upadhyay --- pkg/hub/controllers/cluster/reconciler.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/hub/controllers/cluster/reconciler.go b/pkg/hub/controllers/cluster/reconciler.go index 1ddb19f14..5e15959df 100644 --- a/pkg/hub/controllers/cluster/reconciler.go +++ b/pkg/hub/controllers/cluster/reconciler.go @@ -96,9 +96,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco if cr == nil { return reconcile.Result{}, err } - if cr.Status.RegistrationStatus == "" { - cr.Status.RegistrationStatus = hubv1alpha1.RegistrationStatusInProgress - } + log.Info("got cluster CR from hub", "cluster", cr) requeue, result, err := r.handleClusterDeletion(cr, ctx, req) if requeue { @@ -412,20 +410,19 @@ func (r *Reconciler) updateCNISubnetConfig(ctx context.Context, cr *hubv1alpha1. if err != nil { return err } - cniSubnet := []string{} // nsm-config is present only when operator is installed with networking enabled if cr.Status.NetworkPresent { debuglog.Info("try to get cni subnets from nsm-config cm") - cniSubnet, err = cl.GetNsmExcludedPrefix(ctx, "nsm-config", "kubeslice-system") + cniSubnet, err := cl.GetNsmExcludedPrefix(ctx, "nsm-config", "kubeslice-system") if err != nil { log.Error(err, "Failed to get nsm config") return err } - } - if !reflect.DeepEqual(cr.Status.CniSubnet, cniSubnet) { - cr.Status.CniSubnet = cniSubnet - toUpdate = true - return r.Status().Update(ctx, cr) + if !reflect.DeepEqual(cr.Status.CniSubnet, cniSubnet) { + cr.Status.CniSubnet = cniSubnet + toUpdate = true + return r.Status().Update(ctx, cr) + } } return nil })