浏览代码

Merge pull request #35563 from soccerGB/driveroptionpersist

Added support for persisting Windows network driver specific options …
Yong Tang 7 年之前
父节点
当前提交
1f3f111b45
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      daemon/daemon_windows.go

+ 13 - 1
daemon/daemon_windows.go

@@ -350,6 +350,9 @@ func (daemon *Daemon) initNetworkController(config *config.Config, activeSandbox
 		}
 		}
 
 
 		controller.WalkNetworks(s)
 		controller.WalkNetworks(s)
+
+		drvOptions := make(map[string]string)
+
 		if n != nil {
 		if n != nil {
 			// global networks should not be deleted by local HNS
 			// global networks should not be deleted by local HNS
 			if n.Info().Scope() == datastore.GlobalScope {
 			if n.Info().Scope() == datastore.GlobalScope {
@@ -358,14 +361,23 @@ func (daemon *Daemon) initNetworkController(config *config.Config, activeSandbox
 			v.Name = n.Name()
 			v.Name = n.Name()
 			// This will not cause network delete from HNS as the network
 			// This will not cause network delete from HNS as the network
 			// is not yet populated in the libnetwork windows driver
 			// is not yet populated in the libnetwork windows driver
+
+			// restore option if it existed before
+			drvOptions = n.Info().DriverOptions()
 			n.Delete()
 			n.Delete()
 		}
 		}
-
 		netOption := map[string]string{
 		netOption := map[string]string{
 			winlibnetwork.NetworkName: v.Name,
 			winlibnetwork.NetworkName: v.Name,
 			winlibnetwork.HNSID:       v.Id,
 			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{}
 		v4Conf := []*libnetwork.IpamConf{}
 		for _, subnet := range v.Subnets {
 		for _, subnet := range v.Subnets {
 			ipamV4Conf := libnetwork.IpamConf{}
 			ipamV4Conf := libnetwork.IpamConf{}