mirror of https://github.com/k3s-io/k3s
Merge pull request #426 from galal-hussein/check_hostname
Check if hostname is resolvable before running agentpull/429/head
commit
93e9f50395
|
@ -253,6 +253,8 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostnameCheck(nodeName)
|
||||||
|
|
||||||
nodeCertFile := filepath.Join(envInfo.DataDir, "token-node.crt")
|
nodeCertFile := filepath.Join(envInfo.DataDir, "token-node.crt")
|
||||||
nodeKeyFile := filepath.Join(envInfo.DataDir, "token-node.key")
|
nodeKeyFile := filepath.Join(envInfo.DataDir, "token-node.key")
|
||||||
nodePasswordFile := filepath.Join(envInfo.DataDir, "node-password.txt")
|
nodePasswordFile := filepath.Join(envInfo.DataDir, "node-password.txt")
|
||||||
|
@ -348,3 +350,14 @@ func getConfig(info *clientaccess.Info) (*config.Control, error) {
|
||||||
controlControl := &config.Control{}
|
controlControl := &config.Control{}
|
||||||
return controlControl, json.Unmarshal(data, controlControl)
|
return controlControl, json.Unmarshal(data, controlControl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hostnameCheck(hostname string) {
|
||||||
|
for {
|
||||||
|
_, err := sysnet.LookupHost(hostname)
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
logrus.Infof("Waiting for hostname %s to be resolvable: %v", hostname, err)
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue