Skip to content
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

test: Avoid panics due to dereferencing a nil error #10390

Merged
merged 1 commit into from Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/helpers/kubectl.go
Expand Up @@ -852,11 +852,11 @@ func (kub *Kubectl) NamespaceDelete(name string) *CmdRes {
ginkgoext.By("Deleting namespace %s", name)
res := kub.DeleteAllInNamespace(name)
if !res.WasSuccessful() {
kub.Logger().Infof("Error while deleting all objects from %s ns: %s", name, res.GetError().Error())
kub.Logger().Infof("Error while deleting all objects from %s ns: %s", name, res.GetError())
}
res = kub.ExecShort(fmt.Sprintf("%s delete namespace %s", KubectlCmd, name))
if !res.WasSuccessful() {
kub.Logger().Infof("Error while deleting ns %s: %s", name, res.GetError().Error())
kub.Logger().Infof("Error while deleting ns %s: %s", name, res.GetError())
}
return kub.ExecShort(fmt.Sprintf(
"%[1]s get namespace %[2]s -o json | tr -d \"\\n\" | sed \"s/\\\"finalizers\\\": \\[[^]]\\+\\]/\\\"finalizers\\\": []/\" | %[1]s replace --raw /api/v1/namespaces/%[2]s/finalize -f -", KubectlCmd, name))
Expand Down
5 changes: 4 additions & 1 deletion test/helpers/node.go
Expand Up @@ -229,8 +229,8 @@ func (s *SSHMeta) ExecContext(ctx context.Context, cmd string, options ...ExecOp
} else {
// Log other error types. They are likely from SSH or the network
log.WithError(err).Errorf("Error executing command '%s'", cmd)
res.err = err
}
res.err = err
}

res.SendToLog(ops.SkipLog)
Expand Down Expand Up @@ -306,6 +306,9 @@ func (s *SSHMeta) ExecInBackground(ctx context.Context, cmd string, options ...E
res.success = true
}
}
if !res.success {
res.err = err
}
} else {
res.success = true
res.exitcode = 0
Expand Down