mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fixed a few more issues observed during docker integration
- DisableBridgeCreation is misleading. change it to DefaultBridge - Dont fail the init if localstore cannot be initialized - added a convenience function to get endpoint for a container Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
7305922385
commit
a41025e9c0
8 changed files with 32 additions and 28 deletions
|
@ -163,7 +163,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
|
||||||
log.Debugf("Failed to Initialize Discovery : %v", err)
|
log.Debugf("Failed to Initialize Discovery : %v", err)
|
||||||
}
|
}
|
||||||
if err := c.initLocalStore(); err != nil {
|
if err := c.initLocalStore(); err != nil {
|
||||||
return nil, fmt.Errorf("Failed to Initialize LocalDatastore due to %v.", err)
|
log.Debugf("Failed to Initialize LocalDatastore due to %v.", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,18 +48,18 @@ type configuration struct {
|
||||||
|
|
||||||
// networkConfiguration for network specific configuration
|
// networkConfiguration for network specific configuration
|
||||||
type networkConfiguration struct {
|
type networkConfiguration struct {
|
||||||
BridgeName string
|
BridgeName string
|
||||||
AddressIPv4 *net.IPNet
|
AddressIPv4 *net.IPNet
|
||||||
FixedCIDR *net.IPNet
|
FixedCIDR *net.IPNet
|
||||||
FixedCIDRv6 *net.IPNet
|
FixedCIDRv6 *net.IPNet
|
||||||
EnableIPv6 bool
|
EnableIPv6 bool
|
||||||
EnableIPMasquerade bool
|
EnableIPMasquerade bool
|
||||||
EnableICC bool
|
EnableICC bool
|
||||||
Mtu int
|
Mtu int
|
||||||
DefaultGatewayIPv4 net.IP
|
DefaultGatewayIPv4 net.IP
|
||||||
DefaultGatewayIPv6 net.IP
|
DefaultGatewayIPv6 net.IP
|
||||||
DefaultBindingIP net.IP
|
DefaultBindingIP net.IP
|
||||||
DisableBridgeCreation bool
|
DefaultBridge bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// endpointConfiguration represents the user specified configuration for the sandbox endpoint
|
// 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["DisableBridgeCreation"]; ok && i != nil {
|
if i, ok := data["DefaultBridge"]; ok && i != nil {
|
||||||
if s, ok := i.(string); ok {
|
if s, ok := i.(string); ok {
|
||||||
if c.DisableBridgeCreation, err = strconv.ParseBool(s); err != nil {
|
if c.DefaultBridge, err = strconv.ParseBool(s); err != nil {
|
||||||
return types.BadRequestErrorf("failed to parse DisableBridgeCreation value: %s", err.Error())
|
return types.BadRequestErrorf("failed to parse DefaultBridge value: %s", err.Error())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return types.BadRequestErrorf("invalid type for DisableBridgeCreation value")
|
return types.BadRequestErrorf("invalid type for DefaultBridge value")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ func parseNetworkOptions(id string, option options.Generic) (*networkConfigurati
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.BridgeName == "" && config.DisableBridgeCreation == false {
|
if config.BridgeName == "" && config.DefaultBridge == false {
|
||||||
config.BridgeName = "br-" + id[:12]
|
config.BridgeName = "br-" + id[:12]
|
||||||
}
|
}
|
||||||
return config, nil
|
return config, nil
|
||||||
|
|
|
@ -123,7 +123,7 @@ func TestCreateFail(t *testing.T) {
|
||||||
t.Fatalf("Failed to setup driver config: %v", err)
|
t.Fatalf("Failed to setup driver config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
netconfig := &networkConfiguration{BridgeName: "dummy0", DisableBridgeCreation: true}
|
netconfig := &networkConfiguration{BridgeName: "dummy0", DefaultBridge: true}
|
||||||
genericOption := make(map[string]interface{})
|
genericOption := make(map[string]interface{})
|
||||||
genericOption[netlabel.GenericData] = netconfig
|
genericOption[netlabel.GenericData] = netconfig
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ func setupDevice(config *networkConfiguration, i *bridgeInterface) error {
|
||||||
|
|
||||||
// We only attempt to create the bridge when the requested device name is
|
// We only attempt to create the bridge when the requested device name is
|
||||||
// the default one.
|
// the default one.
|
||||||
if config.BridgeName != DefaultBridgeName && config.DisableBridgeCreation {
|
if config.BridgeName != DefaultBridgeName && config.DefaultBridge {
|
||||||
return NonDefaultBridgeExistError(config.BridgeName)
|
return NonDefaultBridgeExistError(config.BridgeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestSetupNewBridge(t *testing.T) {
|
||||||
func TestSetupNewNonDefaultBridge(t *testing.T) {
|
func TestSetupNewNonDefaultBridge(t *testing.T) {
|
||||||
defer testutils.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{BridgeName: "test0", DisableBridgeCreation: true}
|
config := &networkConfiguration{BridgeName: "test0", DefaultBridge: true}
|
||||||
br := &bridgeInterface{}
|
br := &bridgeInterface{}
|
||||||
|
|
||||||
err := setupDevice(config, br)
|
err := setupDevice(config, br)
|
||||||
|
|
|
@ -53,7 +53,7 @@ func setupBridgeIPv4(config *networkConfiguration, i *bridgeInterface) error {
|
||||||
|
|
||||||
// Do not try to configure IPv4 on a non-default bridge unless you are
|
// Do not try to configure IPv4 on a non-default bridge unless you are
|
||||||
// specifically asked to do so.
|
// specifically asked to do so.
|
||||||
if config.BridgeName != DefaultBridgeName && config.DisableBridgeCreation {
|
if config.BridgeName != DefaultBridgeName && config.DefaultBridge {
|
||||||
return NonDefaultBridgeNeedsIPError(config.BridgeName)
|
return NonDefaultBridgeNeedsIPError(config.BridgeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (c *controller) acceptClientConnections(sock string, l net.Listener) {
|
||||||
conn, err := l.Accept()
|
conn, err := l.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, err1 := os.Stat(sock); os.IsNotExist(err1) {
|
if _, err1 := os.Stat(sock); os.IsNotExist(err1) {
|
||||||
logrus.Warnf("Unix socket %s doesnt exist. cannot accept client connections", sock)
|
logrus.Debugf("Unix socket %s doesnt exist. cannot accept client connections", sock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logrus.Errorf("Error accepting connection %v", err)
|
logrus.Errorf("Error accepting connection %v", err)
|
||||||
|
|
|
@ -133,14 +133,18 @@ func TestLocalStoreLockTimeout(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error getting random boltdb configs %v", err)
|
t.Fatalf("Error getting random boltdb configs %v", err)
|
||||||
}
|
}
|
||||||
ctrl, err := New(cfgOptions...)
|
ctrl1, err := New(cfgOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error new controller: %v", err)
|
t.Fatalf("Error new controller: %v", err)
|
||||||
}
|
}
|
||||||
defer ctrl.Stop()
|
defer ctrl1.Stop()
|
||||||
// Use the same boltdb file without closing the previous controller
|
// Use the same boltdb file without closing the previous controller
|
||||||
_, err = New(cfgOptions...)
|
ctrl2, _ := New(cfgOptions...)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Fatalf("Multiple boldtdb connection must fail")
|
t.Fatalf("Error new controller: %v", err)
|
||||||
|
}
|
||||||
|
store := ctrl2.(*controller).localStore
|
||||||
|
if store != nil {
|
||||||
|
t.Fatalf("localstore is expected to be nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue