Skip to content

Commit

Permalink
Drop storagenetwork nad from onRemove check
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Wang <[email protected]>
  • Loading branch information
w13915984028 committed Mar 4, 2025
1 parent 9d587ea commit 7009a06
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
5 changes: 0 additions & 5 deletions pkg/webhook/nad/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
32 changes: 0 additions & 32 deletions pkg/webhook/nad/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 7009a06

Please sign in to comment.