Added a new network creation driver option (disable_gatewaydns) for the Windows driver

Signed-off-by: Cheng-mean Liu <soccerl@microsoft.com>
This commit is contained in:
Cheng-mean Liu 2017-11-21 11:35:32 -08:00
parent a41f623b10
commit 5a5b7fee33
3 changed files with 18 additions and 1 deletions

View File

@ -39,4 +39,7 @@ const (
// DisableDNS label
DisableDNS = "com.docker.network.windowsshim.disable_dns"
// DisableGatewayDNS label
DisableGatewayDNS = "com.docker.network.windowsshim.disable_gatewaydns"
)

View File

@ -44,6 +44,7 @@ type networkConfiguration struct {
NetworkAdapterName string
dbIndex uint64
dbExists bool
DisableGatewayDNS bool
}
// endpointConfiguration represents the user specified configuration for the sandbox endpoint
@ -177,6 +178,12 @@ func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string
config.DNSSuffix = value
case DNSServers:
config.DNSServers = value
case DisableGatewayDNS:
b, err := strconv.ParseBool(value)
if err != nil {
return nil, err
}
config.DisableGatewayDNS = b
case MacPool:
config.MacPools = make([]hcsshim.MacPool, 0)
s := strings.Split(value, ",")
@ -589,7 +596,14 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
endpointStruct.DNSServerList = strings.Join(epOption.DNSServers, ",")
// overwrite the ep DisableDNS option if DisableGatewayDNS was set to true during the network creation option
if n.config.DisableGatewayDNS {
logrus.Debugf("n.config.DisableGatewayDNS[%v] overwrites epOption.DisableDNS[%v]", n.config.DisableGatewayDNS, epOption.DisableDNS)
epOption.DisableDNS = n.config.DisableGatewayDNS
}
if n.driver.name == "nat" && !epOption.DisableDNS {
logrus.Debugf("endpointStruct.EnableInternalDNS =[%v]", endpointStruct.EnableInternalDNS)
endpointStruct.EnableInternalDNS = true
}

View File

@ -64,7 +64,7 @@ func (d *driver) populateNetworks() error {
if err = d.createNetwork(ncfg); err != nil {
logrus.Warnf("could not create windows network for id %s hnsid %s while booting up from persistent state: %v", ncfg.ID, ncfg.HnsID, err)
}
logrus.Debugf("Network (%s) restored", ncfg.ID[0:7])
logrus.Debugf("Network %v (%s) restored", d.name, ncfg.ID[0:7])
}
return nil