1
0
mirror of https://github.com/rancher/os.git synced 2025-08-01 06:59:05 +00:00

Add explicit wait to dhcp

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit 2017-06-14 20:45:03 +10:00
parent 5078c80c36
commit 8a741c5d32
3 changed files with 7 additions and 1 deletions

View File

@ -42,6 +42,7 @@ func ApplyNetworkConfig(cfg *config.CloudConfig) {
}
// TODO: don't write to the file if nameservers is still empty
log.Infof("Writing resolv.conf (%v) %v", nameservers, search)
if _, err := resolvconf.Build("/etc/resolv.conf", nameservers, search, nil); err != nil {
log.Error(err)
}

View File

@ -351,6 +351,7 @@ ff02::2 ip6-allrouters
127.0.1.1 `+hostname)
if len(cfg.DNSConfig.Nameservers) != 0 {
log.Infof("Writing resolv.conf (%v) %v", cfg.DNSConfig.Nameservers, cfg.DNSConfig.Search)
if _, err := resolvconf.Build("/etc/resolv.conf", cfg.DNSConfig.Nameservers, cfg.DNSConfig.Search, nil); err != nil {
return err
}

View File

@ -187,7 +187,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig) error {
}
func RunDhcp(netCfg *NetworkConfig, setHostname, setDNS bool) error {
log.Debugf("RunDhcp")
log.Debugf("RunDhcp(%V, %v)", setHostname, setDNS)
populateDefault(netCfg)
links, err := netlink.LinkList()
@ -258,6 +258,10 @@ func runDhcp(netCfg *NetworkConfig, iface string, argstr string, setHostname, se
args = append(args, "--nohook", "resolv.conf")
}
// Wait for lease
// TODO: this should be optional - based on kernel arg?
args = append(args, "-w", "--debug")
args = append(args, iface)
cmd := exec.Command(args[0], args[1:]...)
log.Infof("Running DHCP on %s: %s", iface, strings.Join(args, " "))