Skip to content

Commit 5ad75fd

Browse files
committed
check fail by debug file content
1 parent d85403a commit 5ad75fd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/job_ssh.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,26 @@ func (m ModJobSshStruct) setupClusterInner(clusterConf clusterconf.ClusterConfYm
322322
}
323323
_ = base64.StdEncoding.EncodeToString(pubkeybytes)
324324

325-
output, _ := util.StartRemoteCmds(
325+
output, logfps := util.StartRemoteCmds(
326326
hosts,
327327
// install telego,
328328
util.ModRunCmd.CmdModels().InstallTelegoWithPy()+"; "+
329329
// update authorized_keys
330330
strings.Join(m.NewSshCmd(SshJob{Mode: SshModeSetupThisNode}.ModeString()), " "),
331331
clusterConf.Global.SshPasswd,
332332
)
333-
if strings.Contains(output[0], "ssh error:") {
333+
logfdebug, err := os.ReadFile(logfps[0] + ".debug")
334+
if err != nil {
335+
fmt.Println(color.RedString("read logfdebug failed: %v", err))
336+
os.Exit(1)
337+
}
338+
srcs := []string{output[0], string(logfdebug)}
339+
keywords := []string{"error", "失败"}
340+
if funk.Any(srcs, func(src string) bool {
341+
return funk.Any(keywords, func(keyword string) bool {
342+
return strings.Contains(src, keyword)
343+
})
344+
}) {
334345
fmt.Println(color.RedString("ssh error: %s", output))
335346
// debug sshd_config
336347
util.ModRunCmd.NewBuilder("cat", "/etc/ssh/sshd_config").WithRoot().ShowProgress().BlockRun()

0 commit comments

Comments
 (0)