Merge pull request #47022 from akerouanton/libnet-bridge-dead-check-on-stale-default-nw libnet/d/bridge: dead code: no conflict on stale default nw
diff --git a/libnetwork/drivers/bridge/bridge_linux.go b/libnetwork/drivers/bridge/bridge_linux.go index 700a0e7..005c726 100644 --- a/libnetwork/drivers/bridge/bridge_linux.go +++ b/libnetwork/drivers/bridge/bridge_linux.go
@@ -42,14 +42,6 @@ DefaultGatewayV6AuxKey = "DefaultGatewayIPv6" ) -type defaultBridgeNetworkConflict struct { - ID string -} - -func (d defaultBridgeNetworkConflict) Error() string { - return fmt.Sprintf("Stale default bridge network %s", d.ID) -} - type ( iptableCleanFunc func() error iptablesCleanFuncs []iptableCleanFunc @@ -674,15 +666,7 @@ // check network conflicts if err = d.checkConflict(config); err != nil { - nerr, ok := err.(defaultBridgeNetworkConflict) - if !ok { - return err - } - // Got a conflict with a stale default network, clean that up and continue - log.G(context.TODO()).Warn(nerr) - if err := d.deleteNetwork(nerr.ID); err != nil { - log.G(context.TODO()).WithError(err).Debug("Error while cleaning up network on conflict") - } + return err } // there is no conflict, now create the network @@ -700,15 +684,6 @@ nwConfig := nw.config nw.Unlock() if err := nwConfig.Conflicts(config); err != nil { - if nwConfig.DefaultBridge { - // We encountered and identified a stale default network - // We must delete it as libnetwork is the source of truth - // The default network being created must be the only one - // This can happen only from docker 1.12 on ward - log.G(context.TODO()).Infof("Found stale default bridge network %s (%s)", nwConfig.ID, nwConfig.BridgeName) - return defaultBridgeNetworkConflict{nwConfig.ID} - } - return types.ForbiddenErrorf("cannot create network %s (%s): conflicts with network %s (%s): %s", config.ID, config.BridgeName, nwConfig.ID, nwConfig.BridgeName, err.Error()) }
diff --git a/libnetwork/drivers/bridge/errors.go b/libnetwork/drivers/bridge/errors.go index 8360b32..11532d2 100644 --- a/libnetwork/drivers/bridge/errors.go +++ b/libnetwork/drivers/bridge/errors.go
@@ -104,17 +104,6 @@ // InvalidParameter denotes the type of this error func (uat ErrUnsupportedAddressType) InvalidParameter() {} -// ActiveEndpointsError is returned when there are -// still active endpoints in the network being deleted. -type ActiveEndpointsError string - -func (aee ActiveEndpointsError) Error() string { - return fmt.Sprintf("network %s has active endpoint", string(aee)) -} - -// Forbidden denotes the type of this error -func (aee ActiveEndpointsError) Forbidden() {} - // InvalidNetworkIDError is returned when the passed // network id for an existing network is not a known id. type InvalidNetworkIDError string