From ce7c7b8476d24f7a6cd5d31eeef9a8694deb434f Mon Sep 17 00:00:00 2001 From: Sunyanan Choochotkaew Date: Wed, 10 Jan 2024 09:35:12 +0900 Subject: [PATCH] check active namespace before creating NAD Signed-off-by: Sunyanan Choochotkaew --- plugin/net_attach_def.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/net_attach_def.go b/plugin/net_attach_def.go index 29b7d769..5c78ca4b 100644 --- a/plugin/net_attach_def.go +++ b/plugin/net_attach_def.go @@ -14,6 +14,7 @@ import ( "github.com/containernetworking/cni/pkg/types" multinicv1 "github.com/foundation-model-stack/multi-nic-cni/api/v1" "github.com/foundation-model-stack/multi-nic-cni/controllers/vars" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -147,7 +148,9 @@ func (h *NetAttachDefHandler) getNamespace(net *multinicv1.MultiNicNetwork) ([]s namespaceList, err := h.Clientset.CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) if err == nil { for _, ns := range namespaceList.Items { - namespaces = append(namespaces, ns.Name) + if ns.Status.Phase == v1.NamespaceActive { + namespaces = append(namespaces, ns.Name) + } } } else { return namespaces, err