Skip to content

Commit ac3a83d

Browse files
committed
Change active EP check to consider DNS EP
1 parent 29ecc1a commit ac3a83d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

netmaster/master/network.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ func DeleteNetworkID(stateDriver core.StateDriver, netID string) error {
371371
return err
372372
}
373373

374+
// Check if there are any active endpoints
375+
if hasActiveEndpoints(nwCfg) {
376+
return core.Errorf("Error: Network has active endpoints")
377+
}
378+
374379
if IsDNSEnabled() {
375380
// detach Dns container
376381
err = detachServiceContainer(nwCfg.Tenant, nwCfg.NetworkName)
@@ -379,11 +384,6 @@ func DeleteNetworkID(stateDriver core.StateDriver, netID string) error {
379384
}
380385
}
381386

382-
// Check if there are any active endpoints
383-
if hasActiveEndpoints(nwCfg) {
384-
return core.Errorf("Error: Network has active endpoints")
385-
}
386-
387387
if GetClusterMode() == "docker" {
388388
// Delete the docker network
389389
err = docknet.DeleteDockNet(nwCfg.Tenant, nwCfg.NetworkName, "")
@@ -534,5 +534,7 @@ func networkReleaseAddress(nwCfg *mastercfg.CfgNetworkState, ipAddress string) e
534534
}
535535

536536
func hasActiveEndpoints(nwCfg *mastercfg.CfgNetworkState) bool {
537-
return nwCfg.EpCount > 0
537+
// We spin a dns container if IsDNSEnabled() == true
538+
// We need to exlude that from Active EPs check.
539+
return (IsDNSEnabled() && nwCfg.EpCount > 1) || ((!IsDNSEnabled()) && nwCfg.EpCount > 0)
538540
}

0 commit comments

Comments
 (0)