远程安装节点时uname读取失败时自动重试

This commit is contained in:
GoEdgeLab
2022-11-18 15:57:06 +08:00
parent 8151e30869
commit 854b1efc7a

View File

@@ -147,13 +147,23 @@ func (this *BaseInstaller) LookupLatestInstaller(filePrefix string) (string, err
// InstallHelper 上传安装助手 // InstallHelper 上传安装助手
func (this *BaseInstaller) InstallHelper(targetDir string, role nodeconfigs.NodeRole) (env *Env, err error) { func (this *BaseInstaller) InstallHelper(targetDir string, role nodeconfigs.NodeRole) (env *Env, err error) {
uname, stderr, err := this.client.Exec("/usr/bin/uname -a") var unameRetries = 3
var uname string
for i := 0; i < unameRetries; i++ {
uname, _, err = this.client.Exec("/usr/bin/uname -a")
if len(uname) == 0 {
continue
}
if err == nil {
break
}
}
if err != nil { if err != nil {
return env, err return env, errors.New("unable to execute 'uname -a' on this system: " + err.Error())
} }
if len(uname) == 0 { if len(uname) == 0 {
return nil, errors.New("unable to execute 'uname -a' on this system: " + stderr) return nil, errors.New("unable to execute 'uname -a' on this system")
} }
osName := "" osName := ""