diff --git a/pkg/webhook/nad/validator.go b/pkg/webhook/nad/validator.go index 4cb5540e..13871dfe 100644 --- a/pkg/webhook/nad/validator.go +++ b/pkg/webhook/nad/validator.go @@ -123,11 +123,6 @@ func (v *Validator) Delete(_ *admission.Request, oldObj runtime.Object) error { return fmt.Errorf(deleteErr, nad.Namespace, nad.Name, err) } - // storagenetwork can't be deleted by user, only the harvester storagenetwork controller can - if err := v.checkStorageNetwork(nad); err != nil { - return fmt.Errorf(deleteErr, nad.Namespace, nad.Name, err) - } - return nil } diff --git a/pkg/webhook/nad/validator_test.go b/pkg/webhook/nad/validator_test.go index bf3f5b2e..2cd16b7b 100644 --- a/pkg/webhook/nad/validator_test.go +++ b/pkg/webhook/nad/validator_test.go @@ -13,7 +13,6 @@ import ( networkv1 "github.com/harvester/harvester-network-controller/pkg/apis/network.harvesterhci.io/v1beta1" harvesterfake "github.com/harvester/harvester/pkg/generated/clientset/versioned/fake" - harvesterutil "github.com/harvester/harvester/pkg/util" "github.com/harvester/harvester-network-controller/pkg/generated/clientset/versioned/fake" "github.com/harvester/harvester-network-controller/pkg/utils" @@ -434,37 +433,6 @@ func TestDeleteNAD(t *testing.T) { }, }, }, - { - name: "NAD can't be deleted as it is used by storagenetwork via annotation", - returnErr: true, - errKey: storageNetworkErr, - currentNAD: &cniv1.NetworkAttachmentDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: testNadName, - Namespace: harvesterutil.HarvesterSystemNamespaceName, // storagenetwork nad is in given namespace - Annotations: map[string]string{utils.StorageNetworkAnnotation: "true"}, - Labels: map[string]string{utils.KeyClusterNetworkLabel: testCnName}, - }, - Spec: cniv1.NetworkAttachmentDefinitionSpec{ - Config: testNadConfig, - }, - }, - }, - { - name: "NAD can't be deleted as it is used by storagenetwork via namespace and name", - returnErr: true, - errKey: storageNetworkErr, - currentNAD: &cniv1.NetworkAttachmentDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: utils.StorageNetworkNetAttachDefPrefix + "test", - Namespace: harvesterutil.HarvesterSystemNamespaceName, - Labels: map[string]string{utils.KeyClusterNetworkLabel: testCnName}, - }, - Spec: cniv1.NetworkAttachmentDefinitionSpec{ - Config: testNadConfig, - }, - }, - }, } for _, tc := range tests {