return 0 exit code if failed to get container logs

pull/12246/head
Steven Powell 2021-09-23 13:21:42 -07:00
parent 8c0e46c784
commit e7723c79dd
2 changed files with 2 additions and 17 deletions

View File

@ -28,7 +28,6 @@ import (
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/logs"
"k8s.io/minikube/pkg/minikube/mustload"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
)
@ -97,13 +96,7 @@ var logsCmd = &cobra.Command{
logs.OutputProblems(problems, numberOfProblems, logOutput)
return
}
err = logs.Output(cr, bs, *co.Config, co.CP.Runner, numberOfLines, logOutput)
if err != nil {
out.Ln("")
// Avoid exit.Error, since it outputs the issue URL
out.WarningT("{{.error}}", out.V{"error": err})
os.Exit(reason.ExSvcError)
}
logs.Output(cr, bs, *co.Config, co.CP.Runner, numberOfLines, logOutput)
},
}

View File

@ -163,7 +163,7 @@ func OutputProblems(problems map[string][]string, maxLines int, logOutput *os.Fi
}
// Output displays logs from multiple sources in tail(1) format
func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.ClusterConfig, runner command.Runner, lines int, logOutput *os.File) error {
func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.ClusterConfig, runner command.Runner, lines int, logOutput *os.File) {
cmds := logCommands(r, bs, cfg, lines, false)
cmds["kernel"] = "uptime && uname -a && grep PRETTY /etc/os-release"
@ -176,7 +176,6 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
defer out.SetOutFile(os.Stdout)
sort.Strings(names)
failed := []string{}
for i, name := range names {
if i > 0 {
out.Styled(style.Empty, "")
@ -188,8 +187,6 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
c.Stderr = &b
if rr, err := runner.RunCmd(c); err != nil {
klog.Errorf("command %s failed with error: %v output: %q", rr.Command(), err, rr.Output())
failed = append(failed, name)
continue
}
l := ""
scanner := bufio.NewScanner(&b)
@ -198,11 +195,6 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
}
out.Styled(style.Empty, l)
}
if len(failed) > 0 {
return fmt.Errorf("unable to fetch logs for: %s", strings.Join(failed, ", "))
}
return nil
}
// outputAudit displays the audit logs.