From 870f6d264e7d77bbd6df6da3992547ee8882ca1a Mon Sep 17 00:00:00 2001 From: ubombar Date: Thu, 21 Mar 2024 18:36:30 +0100 Subject: [PATCH] Add parent and owner reference into the namespace --- internal/multitenancy/v1/multitenancy.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/multitenancy/v1/multitenancy.go b/internal/multitenancy/v1/multitenancy.go index 29d5889..8f31bab 100644 --- a/internal/multitenancy/v1/multitenancy.go +++ b/internal/multitenancy/v1/multitenancy.go @@ -18,7 +18,6 @@ package multitenancy import ( "context" - "fmt" antreav1alpha1 "antrea.io/antrea/pkg/apis/crd/v1alpha1" multitenancyv1 "github.com/edgenet-project/edgenet/api/multitenancy/v1" @@ -395,8 +394,6 @@ func (m *multiTenancyManager) SubNamespaceCleanup(ctx context.Context, s *multit return err } - fmt.Println("Deleted successfully") - return nil } @@ -411,6 +408,11 @@ func (m *multiTenancyManager) SetupSubNamespace(ctx context.Context, s *multiten Labels: map[string]string{ "edge-net.io/generated": "true", "edge-net.io/kind": "sub", + "edge-net.io/parent": s.GetNamespace(), + }, + // The owner reference is required to ensure the namespace cannot be deleted before the subnamespace object. + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(s, s.GroupVersionKind()), }, }, }