Refresh special drivers networks if present in store

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2016-06-14 21:34:44 -07:00
parent 3b705e73e6
commit 9328f1ea1e
4 changed files with 20 additions and 6 deletions

View file

@ -203,6 +203,8 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
}
}
c.WalkNetworks(populateSpecial)
// Reserve pools first before doing cleanup. Otherwise the
// cleanups of endpoint/network and sandbox below will
// generate many unnecessary warnings

View file

@ -987,7 +987,7 @@ func (ep *endpoint) assignAddress(ipam ipamapi.Ipam, assignIPv4, assignIPv6 bool
var err error
n := ep.getNetwork()
if n.Type() == "host" || n.Type() == "null" {
if n.hasSpecialDriver() {
return nil
}
@ -1067,7 +1067,7 @@ func (ep *endpoint) assignAddressVersion(ipVer int, ipam ipamapi.Ipam) error {
func (ep *endpoint) releaseAddress() {
n := ep.getNetwork()
if n.Type() == "host" || n.Type() == "null" {
if n.hasSpecialDriver() {
return
}

View file

@ -1123,8 +1123,7 @@ func (n *network) getController() *controller {
}
func (n *network) ipamAllocate() error {
// For now also exclude bridge from using new ipam
if n.Type() == "host" || n.Type() == "null" {
if n.hasSpecialDriver() {
return nil
}
@ -1295,8 +1294,7 @@ func (n *network) ipamAllocateVersion(ipVer int, ipam ipamapi.Ipam) error {
}
func (n *network) ipamRelease() {
// For now exclude host and null
if n.Type() == "host" || n.Type() == "null" {
if n.hasSpecialDriver() {
return
}
ipam, _, err := n.getController().getIPAMDriver(n.ipamType)
@ -1504,3 +1502,8 @@ func (n *network) TableEventRegister(tableName string) error {
n.driverTables = append(n.driverTables, tableName)
return nil
}
// Special drivers are ones which do not need to perform any network plumbing
func (n *network) hasSpecialDriver() bool {
return n.Type() == "host" || n.Type() == "null"
}

View file

@ -464,3 +464,12 @@ func (c *controller) networkCleanup() {
}
}
}
var populateSpecial NetworkWalker = func(nw Network) bool {
if n := nw.(*network); n.hasSpecialDriver() {
if err := n.getController().addNetwork(n); err != nil {
log.Warnf("Failed to populate network %q with driver %q", nw.Name(), nw.Type())
}
}
return false
}