Skip to content

Commit ec4697e

Browse files
author
KOBAYASHI Shinji
committed
Add SSH logs when provisioning with RedHat derivatives
Fixes docker-archive-public#3507 Signed-off-by: KOBAYASHI Shinji <koba@jp.fujitsu.com>
1 parent 91ec013 commit ec4697e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

libmachine/provision/redhat_ssh_commander.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package provision
22

33
import (
4+
"fmt"
5+
46
"github.com/docker/machine/libmachine/drivers"
7+
"github.com/docker/machine/libmachine/log"
58
"github.com/docker/machine/libmachine/ssh"
69
)
710

@@ -15,17 +18,29 @@ func (sshCmder RedHatSSHCommander) SSHCommand(args string) (string, error) {
1518
return "", err
1619
}
1720

21+
log.Debugf("About to run SSH command:\n%s", args)
22+
1823
// redhat needs "-t" for tty allocation on ssh therefore we check for the
1924
// external client and add as needed.
2025
// Note: CentOS 7.0 needs multiple "-tt" to force tty allocation when ssh has
2126
// no local tty.
27+
var output string
2228
switch c := client.(type) {
2329
case *ssh.ExternalClient:
2430
c.BaseArgs = append(c.BaseArgs, "-tt")
25-
client = c
31+
output, err = c.Output(args)
2632
case *ssh.NativeClient:
27-
return c.OutputWithPty(args)
33+
output, err = c.OutputWithPty(args)
34+
}
35+
36+
log.Debugf("SSH cmd err, output: %v: %s", err, output)
37+
if err != nil {
38+
return "", fmt.Errorf(`Something went wrong running an SSH command!
39+
command : %s
40+
err : %v
41+
output : %s
42+
`, args, err, output)
2843
}
2944

30-
return client.Output(args)
45+
return output, nil
3146
}

0 commit comments

Comments
 (0)