Merge pull request #37583 from mtaufen/test-fr-ssh-issue

Automatic merge from submit-queue

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.
This commit is contained in:
Kubernetes Submit Queue 2016-11-29 23:25:23 -08:00 committed by GitHub
commit 320b30479f

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
}