未验证 提交 e4d32a76 编写于 作者: M Medya Ghazizadeh 提交者: GitHub

Merge pull request #10839 from spowelljr/fixLogsOutput

Show last start and audit logs on `minikube logs` if minikube not running
......@@ -52,6 +52,8 @@ var logsCmd = &cobra.Command{
Short: "Returns logs to debug a local Kubernetes cluster",
Long: `Gets the logs of the running instance, used for debugging minikube, not user code.`,
Run: func(cmd *cobra.Command, args []string) {
logs.OutputOffline(numberOfLines)
co := mustload.Running(ClusterFlagValue())
bs, err := cluster.Bootstrapper(co.API, viper.GetString(cmdcfg.Bootstrapper), *co.Config, co.CP.Runner)
......
......@@ -190,16 +190,6 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
}
}
if err := outputAudit(lines); err != nil {
klog.Errorf("failed to output audit logs: %v", err)
failed = append(failed, "audit")
}
if err := outputLastStart(); err != nil {
klog.Errorf("failed to output last start logs: %v", err)
failed = append(failed, "last start")
}
if len(failed) > 0 {
return fmt.Errorf("unable to fetch logs for: %s", strings.Join(failed, ", "))
}
......@@ -243,6 +233,17 @@ func outputLastStart() error {
return nil
}
// OutputOffline outputs logs that don't need a running cluster.
func OutputOffline(lines int) {
if err := outputAudit(lines); err != nil {
klog.Errorf("failed to output audit logs: %v", err)
}
if err := outputLastStart(); err != nil {
klog.Errorf("failed to output last start logs: %v", err)
}
out.Styled(style.Empty, "")
}
// logCommands returns a list of commands that would be run to receive the anticipated logs
func logCommands(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.ClusterConfig, length int, follow bool) map[string]string {
cmds := bs.LogCommands(cfg, bootstrapper.LogOptions{Lines: length, Follow: follow})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册