return 0 exit code if failed to get container logs
parent
8c0e46c784
commit
e7723c79dd
|
@ -28,7 +28,6 @@ import (
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
"k8s.io/minikube/pkg/minikube/logs"
|
"k8s.io/minikube/pkg/minikube/logs"
|
||||||
"k8s.io/minikube/pkg/minikube/mustload"
|
"k8s.io/minikube/pkg/minikube/mustload"
|
||||||
"k8s.io/minikube/pkg/minikube/out"
|
|
||||||
"k8s.io/minikube/pkg/minikube/reason"
|
"k8s.io/minikube/pkg/minikube/reason"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -97,13 +96,7 @@ var logsCmd = &cobra.Command{
|
||||||
logs.OutputProblems(problems, numberOfProblems, logOutput)
|
logs.OutputProblems(problems, numberOfProblems, logOutput)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = logs.Output(cr, bs, *co.Config, co.CP.Runner, numberOfLines, logOutput)
|
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)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// 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 := logCommands(r, bs, cfg, lines, false)
|
||||||
cmds["kernel"] = "uptime && uname -a && grep PRETTY /etc/os-release"
|
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)
|
defer out.SetOutFile(os.Stdout)
|
||||||
|
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
failed := []string{}
|
|
||||||
for i, name := range names {
|
for i, name := range names {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
out.Styled(style.Empty, "")
|
out.Styled(style.Empty, "")
|
||||||
|
@ -188,8 +187,6 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
|
||||||
c.Stderr = &b
|
c.Stderr = &b
|
||||||
if rr, err := runner.RunCmd(c); err != nil {
|
if rr, err := runner.RunCmd(c); err != nil {
|
||||||
klog.Errorf("command %s failed with error: %v output: %q", rr.Command(), err, rr.Output())
|
klog.Errorf("command %s failed with error: %v output: %q", rr.Command(), err, rr.Output())
|
||||||
failed = append(failed, name)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
l := ""
|
l := ""
|
||||||
scanner := bufio.NewScanner(&b)
|
scanner := bufio.NewScanner(&b)
|
||||||
|
@ -198,11 +195,6 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
|
||||||
}
|
}
|
||||||
out.Styled(style.Empty, l)
|
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.
|
// outputAudit displays the audit logs.
|
||||||
|
|
Loading…
Reference in New Issue