Skip to content

Commit

Permalink
fix(): Refactor cluster reconciliation and update CNI subnet configur…
Browse files Browse the repository at this point in the history
…ation

Signed-off-by: Priyank Upadhyay <[email protected]>
  • Loading branch information
priyank-upadhyay committed Apr 2, 2024
1 parent 3e9f4a2 commit b4db11a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkg/hub/controllers/cluster/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
})
Expand Down

0 comments on commit b4db11a

Please sign in to comment.