-
Notifications
You must be signed in to change notification settings - Fork 39.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nil pointer dereference in test framework #37583
Conversation
if result.Code != 0 || err != nil { | ||
return fmt.Errorf("failed running %q: %v (exit code %d)", | ||
cmd, err, result.Code) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, result
will never be used. Are you sure golang will not throw out an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code in IssueSSHCommandWithResult
should also be changed.
Check err
first then check result.Code
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline, result
is not a pointer in IssueSSHCommandWithResult
.
Is there a corresponding issue for this? |
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.
f7ea225
to
f789ecd
Compare
Jenkins GCE Node e2e failed for commit f7ea225. Full PR test history. The magic incantation to run this job again is |
LGTM |
Jenkins CRI GCE Node e2e failed for commit f7ea225. Full PR test history. The magic incantation to run this job again is |
Jenkins Kubemark GCE e2e failed for commit f7ea225. Full PR test history. The magic incantation to run this job again is |
Jenkins GCE e2e failed for commit f7ea225. Full PR test history. The magic incantation to run this job again is |
Jenkins GCE etcd3 e2e failed for commit f7ea225. Full PR test history. The magic incantation to run this job again is |
Jenkins kops AWS e2e failed for commit f7ea225. Full PR test history. The magic incantation to run this job again is |
Jenkins GKE smoke e2e failed for commit f789ecd. Full PR test history. The magic incantation to run this job again is |
Jenkins GCI GKE smoke e2e failed for commit f789ecd. Full PR test history. The magic incantation to run this job again is |
@k8s-bot gke e2e test this |
@k8s-bot unit test this |
@lavalamp Any idea why the unit/integration job is stuck? |
@k8s-bot unit test this |
/cc @fejta |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
Commit found in the "release-1.5" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
Checking the
result.Code
prior toerr
in the if statement causes a panic if result isnil
. It turns out the formatting of the error is already inIssueSSHCommandWithResult
, so removing redundant code is enough to fix the issue. Logging the SSH result was also redundant, so I removed that as well.This change is