mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Moving overlay configure out of Init and into network create
Ideally, both overlay and libnetwork core must be changed to support kv-store connection retry. But this is a stop-gap measure to unblock the discovery related PRs. Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
e4e77353c9
commit
7305922385
3 changed files with 17 additions and 16 deletions
|
@ -40,6 +40,10 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}) error {
|
|||
return fmt.Errorf("invalid network id")
|
||||
}
|
||||
|
||||
if err := d.configure(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
n := &network{
|
||||
id: id,
|
||||
driver: d,
|
||||
|
|
|
@ -31,6 +31,7 @@ type driver struct {
|
|||
exitCh chan chan struct{}
|
||||
ifaceName string
|
||||
neighIP string
|
||||
config map[string]interface{}
|
||||
peerDb peerNetworkMap
|
||||
serfInstance *serf.Serf
|
||||
networks networkTable
|
||||
|
@ -80,10 +81,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
|||
peerDb: peerNetworkMap{
|
||||
mp: map[string]peerMap{},
|
||||
},
|
||||
}
|
||||
|
||||
if err := d.configure(config); err != nil {
|
||||
return err
|
||||
config: config,
|
||||
}
|
||||
|
||||
return dc.RegisterDriver(networkType, d, c)
|
||||
|
@ -102,27 +100,27 @@ func Fini(drv driverapi.Driver) {
|
|||
}
|
||||
}
|
||||
|
||||
func (d *driver) configure(option map[string]interface{}) error {
|
||||
func (d *driver) configure() error {
|
||||
var onceDone bool
|
||||
var err error
|
||||
|
||||
if len(option) == 0 {
|
||||
if len(d.config) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
d.Do(func() {
|
||||
onceDone = true
|
||||
|
||||
if ifaceName, ok := option[netlabel.OverlayBindInterface]; ok {
|
||||
if ifaceName, ok := d.config[netlabel.OverlayBindInterface]; ok {
|
||||
d.ifaceName = ifaceName.(string)
|
||||
}
|
||||
|
||||
if neighIP, ok := option[netlabel.OverlayNeighborIP]; ok {
|
||||
if neighIP, ok := d.config[netlabel.OverlayNeighborIP]; ok {
|
||||
d.neighIP = neighIP.(string)
|
||||
}
|
||||
|
||||
provider, provOk := option[netlabel.KVProvider]
|
||||
provURL, urlOk := option[netlabel.KVProviderURL]
|
||||
provider, provOk := d.config[netlabel.KVProvider]
|
||||
provURL, urlOk := d.config[netlabel.KVProviderURL]
|
||||
|
||||
if provOk && urlOk {
|
||||
cfg := &config.DatastoreCfg{
|
||||
|
@ -131,7 +129,7 @@ func (d *driver) configure(option map[string]interface{}) error {
|
|||
Address: provURL.(string),
|
||||
},
|
||||
}
|
||||
provConfig, confOk := option[netlabel.KVProviderConfig]
|
||||
provConfig, confOk := d.config[netlabel.KVProviderConfig]
|
||||
if confOk {
|
||||
cfg.Client.Config = provConfig.(*store.Config)
|
||||
}
|
||||
|
@ -161,10 +159,6 @@ func (d *driver) configure(option map[string]interface{}) error {
|
|||
|
||||
})
|
||||
|
||||
if !onceDone {
|
||||
return fmt.Errorf("config already applied to driver")
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ func setupDriver(t *testing.T) *driverTester {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := dt.d.configure(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return dt
|
||||
}
|
||||
|
||||
|
@ -78,7 +81,7 @@ func TestOverlayNilConfig(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := dt.d.configure(nil); err != nil {
|
||||
if err := dt.d.configure(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue