Skip to content

Commit f5f88ea

Browse files
committed
Fix UDN gateway panic when DelNetwork fails
Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
1 parent 99a1176 commit f5f88ea

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

go-controller/pkg/node/gateway_udn.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,10 @@ func (udng *UserDefinedNetworkGateway) GetNetworkRuleMetadata() string {
400400
return fmt.Sprintf("%s-%d", udng.GetNetworkName(), udng.GetNetworkID())
401401
}
402402

403-
// DelNetwork will be responsible to remove all plumbings
404-
// used by this UDN on the gateway side
403+
// DelNetwork will be responsible to remove all plumbings used by this UDN on
404+
// the gateway side. It's considered invalid to call this instance after
405+
// DelNetwork has returned succesfully.
405406
func (udng *UserDefinedNetworkGateway) DelNetwork() error {
406-
close(udng.reconcile)
407-
408407
vrfDeviceName := util.GetNetworkVRFName(udng.NetInfo)
409408
// delete the iprules for this network
410409
if err := udng.ruleManager.DeleteWithMetadata(udng.GetNetworkRuleMetadata()); err != nil {
@@ -425,7 +424,15 @@ func (udng *UserDefinedNetworkGateway) DelNetwork() error {
425424
return err
426425
}
427426
// delete the management port interface for this network
428-
return udng.deleteUDNManagementPort()
427+
err := udng.deleteUDNManagementPort()
428+
if err != nil {
429+
return err
430+
}
431+
432+
// close channel only when succesful since we can be called multiple times
433+
// on failure
434+
close(udng.reconcile)
435+
return nil
429436
}
430437

431438
// addUDNManagementPort does the following:

0 commit comments

Comments
 (0)