Skip to content

Commit

Permalink
fix(webhooks): use correct network name format
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Yang <poan.yang@suse.com>
  • Loading branch information
FrankYang0529 authored and bk201 committed Oct 6, 2021
1 parent a452886 commit c4a7670
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/webhook/resources/network/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,19 @@ func (v *networkAttachmentDefinitionValidator) getVLAN(namespace string, vid int

func (v *networkAttachmentDefinitionValidator) Delete(request *types.Request, oldObj runtime.Object) error {
netAttachDef := oldObj.(*v1.NetworkAttachmentDefinition)
networkName := netAttachDef.Name

// multus network name can be <networkName> or <namespace>/<networkName>
// ref: https://github.com/kubevirt/client-go/blob/148fa0d1c7e83b7a56606a7ca92394ba6768c9ac/api/v1/schema.go#L1436-L1439
networkName := fmt.Sprintf("%s/%s", netAttachDef.Namespace, netAttachDef.Name)
vms, err := v.vms.GetByIndex(indexeres.VMByNetworkIndex, networkName)
if err != nil {
return err
}
if vmsTmp, err := v.vms.GetByIndex(indexeres.VMByNetworkIndex, netAttachDef.Name); err != nil {
return err
} else {
vms = append(vms, vmsTmp...)
}

if len(vms) > 0 {
vmNameList := make([]string, 0, len(vms))
Expand Down

0 comments on commit c4a7670

Please sign in to comment.