Added support for persisting Windows network driver specific options over reboot or service restart

Signed-off-by: Cheng-mean Liu <soccerl@microsoft.com>
Upstream-commit: cef1578ac46e02d05c86621505631b3be7ca9d72
Component: engine
This commit is contained in:
Cheng-mean Liu
2017-11-21 14:11:12 -08:00
parent 23f0e9211c
commit e6fc3af770
+13 -1
View File
@@ -350,6 +350,9 @@ func (daemon *Daemon) initNetworkController(config *config.Config, activeSandbox
}
controller.WalkNetworks(s)
drvOptions := make(map[string]string)
if n != nil {
// global networks should not be deleted by local HNS
if n.Info().Scope() == datastore.GlobalScope {
@@ -358,14 +361,23 @@ func (daemon *Daemon) initNetworkController(config *config.Config, activeSandbox
v.Name = n.Name()
// This will not cause network delete from HNS as the network
// is not yet populated in the libnetwork windows driver
// restore option if it existed before
drvOptions = n.Info().DriverOptions()
n.Delete()
}
netOption := map[string]string{
winlibnetwork.NetworkName: v.Name,
winlibnetwork.HNSID: v.Id,
}
// add persisted driver options
for k, v := range drvOptions {
if k != winlibnetwork.NetworkName && k != winlibnetwork.HNSID {
netOption[k] = v
}
}
v4Conf := []*libnetwork.IpamConf{}
for _, subnet := range v.Subnets {
ipamV4Conf := libnetwork.IpamConf{}