Skip to content

Commit

Permalink
fix(AM-13396): fix app & dns pods related errors
Browse files Browse the repository at this point in the history
Signed-off-by: Mridul Gain <[email protected]>
  • Loading branch information
mridulgain committed Apr 12, 2024
1 parent 236a5d6 commit 434f939
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
34 changes: 22 additions & 12 deletions controllers/slice/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ func (r *SliceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
return result, err
}

if slice.Status.DNSIP == "" {
requeue, result, err := r.handleDnsSvc(ctx, slice)
if requeue {
return result, err
if slice.Status.SliceConfig.SliceOverlayNetworkDeploymentMode != v1alpha1.NONET {
if slice.Status.DNSIP == "" {
requeue, result, err := r.handleDnsSvc(ctx, slice)
if requeue {
return result, err
}
}
}

Expand Down Expand Up @@ -187,12 +189,18 @@ func (r *SliceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
return r.handleAppPodStatusChange(appPods, slice, ctx)
}

debugLog.Info("reconciling app pods")
res, err, requeue = r.ReconcileAppPod(ctx, slice)
if err != nil {
log.Error(err, "App pod reconciliation failed")
return res, err
if slice.Status.SliceConfig.SliceOverlayNetworkDeploymentMode == v1alpha1.NONET {
debugLog.Info("No communication slice, skipping reconciliation of apppods")
// to support net to no-net switching write a function to remove nsm interfaces, ips, labels with nsmip etc from existing app pods
} else {
debugLog.Info("reconciling app pods")
res, err, requeue = r.ReconcileAppPod(ctx, slice)
if err != nil {
log.Error(err, "App pod reconciliation failed")
return res, err
}
}

if requeue {
// reconciliation success, update the app pod list in controller
log.Info("updating app pod list in hub workersliceconfig status")
Expand Down Expand Up @@ -373,9 +381,11 @@ func (r *SliceReconciler) handleSliceDeletion(slice *kubeslicev1beta1.Slice, ctx
} else {
if controllerutil.ContainsFinalizer(slice, sliceFinalizer) {
log.Info("Deleting slice", "slice", slice.Name)
err := r.SendSliceDeletionEventToNetOp(ctx, req.NamespacedName.Name, req.NamespacedName.Namespace)
if err != nil {
log.Error(err, "Failed to send slice deletetion event to netop")
if slice.Status.SliceConfig.SliceOverlayNetworkDeploymentMode != v1alpha1.NONET {
err := r.SendSliceDeletionEventToNetOp(ctx, req.NamespacedName.Name, req.NamespacedName.Namespace)
if err != nil {
log.Error(err, "Failed to send slice deletetion event to netop")
}
}
if err := r.cleanupSliceResources(ctx, slice); err != nil {
log.Error(err, "error while deleting slice")
Expand Down
10 changes: 7 additions & 3 deletions controllers/slice/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package slice
import (
"context"

"github.com/kubeslice/apis/pkg/controller/v1alpha1"
kubeslicev1beta1 "github.com/kubeslice/worker-operator/api/v1beta1"
"github.com/kubeslice/worker-operator/controllers"
corev1 "k8s.io/api/core/v1"
Expand All @@ -35,9 +36,12 @@ func (r *SliceReconciler) cleanupSliceResources(ctx context.Context, slice *kube
if err := r.cleanupSliceNamespaces(ctx, slice); err != nil {
return err
}
//cleanup slice router network service
if err := r.cleanupVl3NSE(ctx, slice.Name); err != nil {
return err
// the crd itself will be absent for no communication slice. skip!
if slice.Status.SliceConfig.SliceOverlayNetworkDeploymentMode != v1alpha1.NONET {
//cleanup slice router network service
if err := r.cleanupVl3NSE(ctx, slice.Name); err != nil {
return err
}
}
//cleanup Service Discovery objects - serviceimport and export objects that belong to this slice
if err := r.cleanupServiceDiscoveryObjects(ctx, slice.Name); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/hub/controllers/cluster/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
debuglog.Info("cluster status", "cr.Status.NetworkPresent", cr.Status.NetworkPresent)
if err = r.updateNetworkStatus(ctx, cr); err != nil {
log.Error(err, "unable to update networkPresent status")
return reconcile.Result{}, err
}
res, err, requeue = r.updateCNISubnetConfig(ctx, cr, cl)
if err != nil {
Expand Down Expand Up @@ -423,6 +424,13 @@ func (r *Reconciler) updateCNISubnetConfig(ctx context.Context, cr *hubv1alpha1.
toUpdate = true
return r.Status().Update(ctx, cr)
}
} else {
debuglog.Info("kubeslice networking is disabled, cni subnet list update is not required")
if len(cr.Status.CniSubnet) > 0 {
debuglog.Info("removing old CNI subnet entries")
cr.Status.CniSubnet = []string{}
return r.Status().Update(ctx, cr)
}
}
return nil
})
Expand Down

0 comments on commit 434f939

Please sign in to comment.