Merge pull request #560 from mavenugo/adb
Flip the default for the flag AllowNonDefaultBridge in bridge driver
This commit is contained in:
commit
51699b91aa
|
@ -291,9 +291,6 @@ func processCreateDefaults(c libnetwork.NetworkController, nc *networkCreate) {
|
|||
if _, ok := gData["BridgeName"]; !ok {
|
||||
gData["BridgeName"] = nc.Name
|
||||
}
|
||||
if _, ok := gData["AllowNonDefaultBridge"]; !ok {
|
||||
gData["AllowNonDefaultBridge"] = "true"
|
||||
}
|
||||
nc.Options[netlabel.GenericData] = genericData
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,6 @@ func createTestNetwork(t *testing.T, network string) (libnetwork.NetworkControll
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": network,
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
netGeneric := libnetwork.NetworkOptionGeneric(netOption)
|
||||
|
@ -213,7 +212,6 @@ func TestCreateDeleteNetwork(t *testing.T) {
|
|||
netlabel.EnableIPv6: true,
|
||||
netlabel.GenericData: map[string]string{
|
||||
"BridgeName": "abc",
|
||||
"AllowNonDefaultBridge": "true",
|
||||
"FixedCIDRv6": "fe80::1/64",
|
||||
"AddressIP": "172.28.30.254/24",
|
||||
},
|
||||
|
@ -260,7 +258,6 @@ func TestGetNetworksAndEndpoints(t *testing.T) {
|
|||
ops := options.Generic{
|
||||
netlabel.GenericData: map[string]string{
|
||||
"BridgeName": "api_test_nw",
|
||||
"AllowNonDefaultBridge": "true",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -532,7 +529,6 @@ func TestProcGetServices(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": netName1,
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
nw1, err := c.NewNetwork(bridgeNetType, netName1, libnetwork.NetworkOptionGeneric(netOption))
|
||||
|
@ -544,7 +540,6 @@ func TestProcGetServices(t *testing.T) {
|
|||
netOption = options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": netName2,
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
nw2, err := c.NewNetwork(bridgeNetType, netName2, libnetwork.NetworkOptionGeneric(netOption))
|
||||
|
@ -1788,7 +1783,6 @@ func TestEndToEnd(t *testing.T) {
|
|||
"EnableIPTables": "true",
|
||||
"AddressIP": "172.28.30.254/16",
|
||||
"EnableUserlandProxy": "true",
|
||||
"AllowNonDefaultBridge": "true",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,6 @@ func createDefaultNetwork(c libnetwork.NetworkController) {
|
|||
if d == "bridge" {
|
||||
genericOption[netlabel.GenericData] = map[string]interface{}{
|
||||
"BridgeName": nw,
|
||||
"AllowNonDefaultBridge": "true",
|
||||
}
|
||||
networkOption := libnetwork.NetworkOptionGeneric(genericOption)
|
||||
createOptions = append(createOptions, networkOption)
|
||||
|
|
|
@ -96,7 +96,6 @@ func (c *controller) createGWNetwork() (Network, error) {
|
|||
netOption := options.Generic{
|
||||
"BridgeName": libnGWNetwork,
|
||||
"EnableICC": false,
|
||||
"AllowNonDefaultBridge": true,
|
||||
"EnableIPMasquerade": true,
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ type networkConfiguration struct {
|
|||
DefaultGatewayIPv4 net.IP
|
||||
DefaultGatewayIPv6 net.IP
|
||||
DefaultBindingIP net.IP
|
||||
AllowNonDefaultBridge bool
|
||||
DisableBridgeCreation bool
|
||||
}
|
||||
|
||||
// endpointConfiguration represents the user specified configuration for the sandbox endpoint
|
||||
|
@ -249,13 +249,13 @@ func (c *networkConfiguration) fromMap(data map[string]interface{}) error {
|
|||
}
|
||||
}
|
||||
|
||||
if i, ok := data["AllowNonDefaultBridge"]; ok && i != nil {
|
||||
if i, ok := data["DisableBridgeCreation"]; ok && i != nil {
|
||||
if s, ok := i.(string); ok {
|
||||
if c.AllowNonDefaultBridge, err = strconv.ParseBool(s); err != nil {
|
||||
return types.BadRequestErrorf("failed to parse AllowNonDefaultBridge value: %s", err.Error())
|
||||
if c.DisableBridgeCreation, err = strconv.ParseBool(s); err != nil {
|
||||
return types.BadRequestErrorf("failed to parse DisableBridgeCreation value: %s", err.Error())
|
||||
}
|
||||
} else {
|
||||
return types.BadRequestErrorf("invalid type for AllowNonDefaultBridge value")
|
||||
return types.BadRequestErrorf("invalid type for DisableBridgeCreation value")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ func TestCreateFail(t *testing.T) {
|
|||
t.Fatalf("Failed to setup driver config: %v", err)
|
||||
}
|
||||
|
||||
netconfig := &networkConfiguration{BridgeName: "dummy0"}
|
||||
netconfig := &networkConfiguration{BridgeName: "dummy0", DisableBridgeCreation: true}
|
||||
genericOption := make(map[string]interface{})
|
||||
genericOption[netlabel.GenericData] = netconfig
|
||||
|
||||
|
@ -146,20 +146,20 @@ func TestCreateMultipleNetworks(t *testing.T) {
|
|||
t.Fatalf("Failed to setup driver config: %v", err)
|
||||
}
|
||||
|
||||
config1 := &networkConfiguration{BridgeName: "net_test_1", AllowNonDefaultBridge: true}
|
||||
config1 := &networkConfiguration{BridgeName: "net_test_1"}
|
||||
genericOption = make(map[string]interface{})
|
||||
genericOption[netlabel.GenericData] = config1
|
||||
if err := d.CreateNetwork("1", genericOption); err != nil {
|
||||
t.Fatalf("Failed to create bridge: %v", err)
|
||||
}
|
||||
|
||||
config2 := &networkConfiguration{BridgeName: "net_test_2", AllowNonDefaultBridge: true}
|
||||
config2 := &networkConfiguration{BridgeName: "net_test_2"}
|
||||
genericOption[netlabel.GenericData] = config2
|
||||
if err := d.CreateNetwork("2", genericOption); err != nil {
|
||||
t.Fatalf("Failed to create bridge: %v", err)
|
||||
}
|
||||
|
||||
config3 := &networkConfiguration{BridgeName: "net_test_3", AllowNonDefaultBridge: true}
|
||||
config3 := &networkConfiguration{BridgeName: "net_test_3"}
|
||||
genericOption[netlabel.GenericData] = config3
|
||||
if err := d.CreateNetwork("3", genericOption); err != nil {
|
||||
t.Fatalf("Failed to create bridge: %v", err)
|
||||
|
@ -168,7 +168,7 @@ func TestCreateMultipleNetworks(t *testing.T) {
|
|||
// Verify the network isolation rules are installed, each network subnet should appear 4 times
|
||||
verifyV4INCEntries(d.networks, 4, t)
|
||||
|
||||
config4 := &networkConfiguration{BridgeName: "net_test_4", AllowNonDefaultBridge: true}
|
||||
config4 := &networkConfiguration{BridgeName: "net_test_4"}
|
||||
genericOption[netlabel.GenericData] = config4
|
||||
if err := d.CreateNetwork("4", genericOption); err != nil {
|
||||
t.Fatalf("Failed to create bridge: %v", err)
|
||||
|
|
|
@ -211,6 +211,17 @@ func (ndbee NonDefaultBridgeExistError) Error() string {
|
|||
// Forbidden denotes the type of this error
|
||||
func (ndbee NonDefaultBridgeExistError) Forbidden() {}
|
||||
|
||||
// NonDefaultBridgeNeedsIPError is returned when a non-default
|
||||
// bridge config is passed but it has no ip configured
|
||||
type NonDefaultBridgeNeedsIPError string
|
||||
|
||||
func (ndbee NonDefaultBridgeNeedsIPError) Error() string {
|
||||
return fmt.Sprintf("bridge device with non default name %s must have a valid IP address", string(ndbee))
|
||||
}
|
||||
|
||||
// Forbidden denotes the type of this error
|
||||
func (ndbee NonDefaultBridgeNeedsIPError) Forbidden() {}
|
||||
|
||||
// FixedCIDRv4Error is returned when fixed-cidrv4 configuration
|
||||
// failed.
|
||||
type FixedCIDRv4Error struct {
|
||||
|
|
|
@ -15,7 +15,7 @@ func setupDevice(config *networkConfiguration, i *bridgeInterface) error {
|
|||
|
||||
// We only attempt to create the bridge when the requested device name is
|
||||
// the default one.
|
||||
if config.BridgeName != DefaultBridgeName && !config.AllowNonDefaultBridge {
|
||||
if config.BridgeName != DefaultBridgeName && config.DisableBridgeCreation {
|
||||
return NonDefaultBridgeExistError(config.BridgeName)
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestSetupNewBridge(t *testing.T) {
|
|||
func TestSetupNewNonDefaultBridge(t *testing.T) {
|
||||
defer testutils.SetupTestOSContext(t)()
|
||||
|
||||
config := &networkConfiguration{BridgeName: "test0"}
|
||||
config := &networkConfiguration{BridgeName: "test0", DisableBridgeCreation: true}
|
||||
br := &bridgeInterface{}
|
||||
|
||||
err := setupDevice(config, br)
|
||||
|
|
|
@ -53,8 +53,8 @@ func setupBridgeIPv4(config *networkConfiguration, i *bridgeInterface) error {
|
|||
|
||||
// Do not try to configure IPv4 on a non-default bridge unless you are
|
||||
// specifically asked to do so.
|
||||
if config.BridgeName != DefaultBridgeName && !config.AllowNonDefaultBridge {
|
||||
return NonDefaultBridgeExistError(config.BridgeName)
|
||||
if config.BridgeName != DefaultBridgeName && config.DisableBridgeCreation {
|
||||
return NonDefaultBridgeNeedsIPError(config.BridgeName)
|
||||
}
|
||||
|
||||
bridgeIPv4, err := electBridgeIPv4(config)
|
||||
|
|
|
@ -296,7 +296,6 @@ func TestBridge(t *testing.T) {
|
|||
"FixedCIDRv6": cidrv6,
|
||||
"EnableIPv6": true,
|
||||
"EnableICC": true,
|
||||
"AllowNonDefaultBridge": true,
|
||||
"EnableIPMasquerade": true,
|
||||
},
|
||||
}
|
||||
|
@ -392,7 +391,6 @@ func TestNetworkName(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -429,7 +427,6 @@ func TestNetworkType(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -456,7 +453,6 @@ func TestNetworkID(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -482,7 +478,7 @@ func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
|||
|
||||
netOption := options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true}
|
||||
}
|
||||
option := options.Generic{
|
||||
netlabel.GenericData: netOption,
|
||||
}
|
||||
|
@ -523,7 +519,7 @@ func TestUnknownNetwork(t *testing.T) {
|
|||
|
||||
netOption := options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true}
|
||||
}
|
||||
option := options.Generic{
|
||||
netlabel.GenericData: netOption,
|
||||
}
|
||||
|
@ -562,7 +558,7 @@ func TestUnknownEndpoint(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AddressIPv4": subnet,
|
||||
"AllowNonDefaultBridge": true}
|
||||
}
|
||||
option := options.Generic{
|
||||
netlabel.GenericData: netOption,
|
||||
}
|
||||
|
@ -605,7 +601,6 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "network1",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -678,7 +673,6 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
|||
netOption = options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "network2",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -736,7 +730,6 @@ func TestDuplicateEndpoint(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
n, err := createTestNetwork(bridgeNetType, "testnetwork", netOption)
|
||||
|
@ -787,7 +780,6 @@ func TestControllerQuery(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "network1",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
net1, err := createTestNetwork(bridgeNetType, "network1", netOption)
|
||||
|
@ -804,7 +796,6 @@ func TestControllerQuery(t *testing.T) {
|
|||
netOption = options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "network2",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
net2, err := createTestNetwork(bridgeNetType, "network2", netOption)
|
||||
|
@ -891,7 +882,6 @@ func TestNetworkQuery(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "network1",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
net1, err := createTestNetwork(bridgeNetType, "network1", netOption)
|
||||
|
@ -1013,7 +1003,6 @@ func TestEndpointJoin(t *testing.T) {
|
|||
n1, err := createTestNetwork(bridgeNetType, "testnetwork1", options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork1",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1124,7 +1113,6 @@ func TestEndpointJoin(t *testing.T) {
|
|||
options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork2",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1216,7 +1204,6 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
|||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1366,7 +1353,6 @@ func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
|||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1430,7 +1416,6 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
|||
n, err := createTestNetwork(bridgeNetType, "testmultiple", options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testmultiple",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1502,7 +1487,6 @@ func TestLeaveAll(t *testing.T) {
|
|||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1566,7 +1550,6 @@ func TestontainerInvalidLeave(t *testing.T) {
|
|||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1633,7 +1616,6 @@ func TestEndpointUpdateParent(t *testing.T) {
|
|||
n, err := createTestNetwork("bridge", "testnetwork", options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1740,7 +1722,6 @@ func TestEnableIPv6(t *testing.T) {
|
|||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"FixedCIDRv6": cidrv6,
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1912,7 +1893,6 @@ func TestResolvConf(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "testnetwork",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
n, err := createTestNetwork("bridge", "testnetwork", netOption)
|
||||
|
@ -2182,7 +2162,6 @@ func createGlobalInstance(t *testing.T) {
|
|||
netOption := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": "network",
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ func getTestEnv(t *testing.T) (NetworkController, Network, Network) {
|
|||
netOption1 := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": name1,
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
n1, err := c.NewNetwork(netType, name1, NetworkOptionGeneric(netOption1))
|
||||
|
@ -48,7 +47,6 @@ func getTestEnv(t *testing.T) (NetworkController, Network, Network) {
|
|||
netOption2 := options.Generic{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"BridgeName": name2,
|
||||
"AllowNonDefaultBridge": true,
|
||||
},
|
||||
}
|
||||
n2, err := c.NewNetwork(netType, name2, NetworkOptionGeneric(netOption2))
|
||||
|
|
Loading…
Reference in New Issue