Skip to content
Open
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
2 changes: 1 addition & 1 deletion controllers/slice/app_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func isAppPodStatusChanged(current []kubeslicev1beta1.AppPod, old []kubeslicev1b
}

for _, cp := range current {
if _, ok := oldPodMap[cp.PodName]; !ok {
if oldPodMap[cp.PodName] != cp.PodIP {
return true
}
}
Expand Down
69 changes: 69 additions & 0 deletions controllers/slice/reconciler_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,72 @@ func TestHandleDnsSvc(t *testing.T) {
})
}
}

func TestIsAppPodStatusChanged(t *testing.T) {
tests := []struct {
name string
current []kubeslicev1beta1.AppPod
old []kubeslicev1beta1.AppPod
want bool
}{
{
name: "same pods same IPs",
current: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.1"},
{PodName: "pod-b", PodIP: "10.0.0.2"},
},
old: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.1"},
{PodName: "pod-b", PodIP: "10.0.0.2"},
},
want: false,
},
{
name: "same pod name different IP",
current: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.99"},
},
old: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.1"},
},
want: true,
},
{
name: "pod added to current",
current: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.1"},
{PodName: "pod-b", PodIP: "10.0.0.2"},
},
old: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.1"},
},
want: true,
},
{
name: "pod removed from current",
current: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.1"},
},
old: []kubeslicev1beta1.AppPod{
{PodName: "pod-a", PodIP: "10.0.0.1"},
{PodName: "pod-b", PodIP: "10.0.0.2"},
},
want: true,
},
{
name: "both empty",
current: []kubeslicev1beta1.AppPod{},
old: []kubeslicev1beta1.AppPod{},
want: false,
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := isAppPodStatusChanged(test.current, test.old)
if got != test.want {
t.Errorf("isAppPodStatusChanged() = %v, want %v", got, test.want)
}
})
}
}
2 changes: 1 addition & 1 deletion controllers/slicegateway/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (r *SliceGwReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
if slice.Status.SliceConfig != nil &&
slice.Status.SliceConfig.SliceOverlayNetworkDeploymentMode == v1alpha1.NONET {
log.Info("No communication slice. Skipping slicegw reconcilation")
return ctrl.Result{}, err
return ctrl.Result{}, nil
}

// Check if slice router network service endpoint (NSE) is present before spawning slice gateway pod.
Expand Down