Fix nil pointer dereference in test framework

Checking the result.Code prior to err in the if statement causes a panic
if result is nil. It turns out the formatting of the error is already in
IssueSSHCommandWithResult, so removing redundant code is enough to fix
the issue. Logging the SSH result was also redundant, so I removed that
as well.
pull/6/head
Michael Taufen 2016-11-28 14:33:16 -08:00
parent cbd87c3a13
commit f789ecdcaf
1 changed files with 3 additions and 9 deletions

View File

@ -3550,16 +3550,10 @@ func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*SSHResult,
}
func IssueSSHCommand(cmd, provider string, node *v1.Node) error {
result, err := IssueSSHCommandWithResult(cmd, provider, node)
if result != nil {
LogSSHResult(*result)
_, err := IssueSSHCommandWithResult(cmd, provider, node)
if err != nil {
return err
}
if result.Code != 0 || err != nil {
return fmt.Errorf("failed running %q: %v (exit code %d)",
cmd, err, result.Code)
}
return nil
}