Skip to content

Commit

Permalink
Revert "Wait to remove network instance while in use"
Browse files Browse the repository at this point in the history
This reverts commit 6f34363.
  • Loading branch information
eriknordmark authored and rvs committed Aug 9, 2021
1 parent 8a83e88 commit 48bb02b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
23 changes: 2 additions & 21 deletions pkg/pillar/cmd/zedrouter/networkinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,30 +380,12 @@ func handleNetworkInstanceDelete(ctxArg interface{}, key string,
if status.Activated {
doNetworkInstanceInactivate(ctx, status)
}
done := maybeNetworkInstanceDelete(ctx, status)
log.Functionf("handleNetworkInstanceDelete(%s) done %t", key, done)
}

// maybeNetworkInstanceDelete checks if the Vifs are gone and if so delete
func maybeNetworkInstanceDelete(ctx *zedrouterContext, status *types.NetworkInstanceStatus) bool {
if lookupNetworkInstanceConfig(ctx, status.Key()) != nil {
log.Functionf("maybeNetworkInstanceDelete(%s) still config",
status.Key())
return false
}

if len(status.Vifs) != 0 {
log.Noticef("maybeNetworkInstanceDelete(%s) still %d Vifs",
status.Key(), len(status.Vifs))
return false
}
doNetworkInstanceDelete(ctx, status)
ctx.networkInstanceStatusMap.Delete(status.UUID)
ctx.pubNetworkInstanceStatus.Unpublish(status.Key())
pub.Unpublish(status.Key())

deleteNetworkInstanceMetrics(ctx, status.Key())
log.Noticef("maybeNetworkInstanceDelete(%s) done", status.Key())
return true
log.Functionf("handleNetworkInstanceDelete(%s) done\n", key)
}

func doNetworkInstanceCreate(ctx *zedrouterContext,
Expand Down Expand Up @@ -1289,7 +1271,6 @@ func doNetworkInstanceInactivate(
switch status.Type {
case types.NetworkInstanceTypeLocal:
natInactivate(ctx, status, false)
// XXX wait until delete and delete waits until all users gone?
deleteServer4(ctx, status.BridgeIPAddr, status.BridgeName)
case types.NetworkInstanceTypeCloud:
vpnInactivate(ctx, status)
Expand Down
10 changes: 3 additions & 7 deletions pkg/pillar/cmd/zedrouter/zedrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,7 @@ func appNetworkDoInactivateUnderlayNetwork(
dnsServers, ntpServers)
startDnsmasq(bridgeName)
}
netstatus.RemoveVif(log, ulStatus.Vif)
if netstatus.Type == types.NetworkInstanceTypeSwitch {
if ulStatus.AccessVlanID <= 1 {
netstatus.NumTrunkPorts--
Expand All @@ -1696,13 +1697,8 @@ func appNetworkDoInactivateUnderlayNetwork(
log.Functionf("set BridgeIPSets to %v for %s", newIpsets, netstatus.Key())
maybeRemoveStaleIpsets(staleIpsets)

netstatus.RemoveVif(log, ulStatus.Vif)
if maybeNetworkInstanceDelete(ctx, netstatus) {
log.Noticef("deleted network instance %s", netstatus.Key())
} else {
// publish the changes to network instance status
publishNetworkInstanceStatus(ctx, netstatus)
}
// publish the changes to network instance status
publishNetworkInstanceStatus(ctx, netstatus)
}

func pkillUserArgs(userName string, match string, printOnError bool) {
Expand Down

0 comments on commit 48bb02b

Please sign in to comment.