Output last start logs during minikube logs
parent
91e8c0980b
commit
f390d1ef0b
|
|
@ -22,7 +22,6 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
|
|
@ -145,7 +144,7 @@ func setFlags() {
|
|||
}
|
||||
}
|
||||
if os.Args[1] == "start" {
|
||||
fp := filepath.Join(localpath.MiniPath(), "logs", "lastStart.txt")
|
||||
fp := localpath.LastStartLog()
|
||||
if err := os.Remove(fp); err != nil {
|
||||
klog.Warningf("Unable to delete file %s: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@ func AuditLog() string {
|
|||
return filepath.Join(MiniPath(), "logs", "audit.json")
|
||||
}
|
||||
|
||||
// LastStartLog returns the path to the last start log.
|
||||
func LastStartLog() string {
|
||||
return filepath.Join(MiniPath(), "logs", "lastStart.txt")
|
||||
}
|
||||
|
||||
// ClientCert returns client certificate path, used by kubeconfig
|
||||
func ClientCert(name string) string {
|
||||
new := filepath.Join(Profile(name), "client.crt")
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
|
@ -34,6 +35,7 @@ import (
|
|||
"k8s.io/minikube/pkg/minikube/command"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/cruntime"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
"k8s.io/minikube/pkg/minikube/style"
|
||||
)
|
||||
|
|
@ -190,10 +192,15 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
|
|||
}
|
||||
|
||||
if err := outputAudit(lines); err != nil {
|
||||
klog.Error(err)
|
||||
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, ", "))
|
||||
}
|
||||
|
|
@ -212,6 +219,19 @@ func outputAudit(lines int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// outputLastStart outputs the last start logs.
|
||||
func outputLastStart() error {
|
||||
out.Step(style.Empty, "")
|
||||
out.Step(style.Empty, "==> Last Start <==")
|
||||
fp := localpath.LastStartLog()
|
||||
l, err := ioutil.ReadFile(fp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read file %s: %v", fp, err)
|
||||
}
|
||||
out.Step(style.Empty, string(l))
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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})
|
||||
|
|
|
|||
Loading…
Reference in New Issue