Skip to content

Commit

Permalink
Merge pull request #3872 from tstromberg/more-logs
Browse files Browse the repository at this point in the history
logs: Add kube-proxy, dmesg, uptime, uname + newlines between log sources
  • Loading branch information
tstromberg authored Mar 20, 2019
2 parents c1a0264 + 0422b9c commit 7f6eeca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
22 changes: 17 additions & 5 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,27 @@ func (k *KubeadmBootstrapper) GetApiServerStatus(ip net.IP) (string, error) {

// LogCommands returns a map of log type to a command which will display that log.
func (k *KubeadmBootstrapper) LogCommands(o bootstrapper.LogOptions) map[string]string {
var kcmd strings.Builder
kcmd.WriteString("journalctl -u kubelet")
var kubelet strings.Builder
kubelet.WriteString("journalctl -u kubelet")
if o.Lines > 0 {
kcmd.WriteString(fmt.Sprintf(" -n %d", o.Lines))
kubelet.WriteString(fmt.Sprintf(" -n %d", o.Lines))
}
if o.Follow {
kcmd.WriteString(" -f")
kubelet.WriteString(" -f")
}

var dmesg strings.Builder
dmesg.WriteString("sudo dmesg -PH -L=never --level warn,err,crit,alert,emerg")
if o.Follow {
dmesg.WriteString(" --follow")
}
if o.Lines > 0 {
dmesg.WriteString(fmt.Sprintf(" | tail -n %d", o.Lines))
}
return map[string]string{
"kubelet": kubelet.String(),
"dmesg": dmesg.String(),
}
return map[string]string{"kubelet": kcmd.String()}
}

func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error {
Expand Down
10 changes: 9 additions & 1 deletion pkg/minikube/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var importantPods = []string{
"kube-apiserver",
"coredns",
"kube-scheduler",
"kube-proxy",
}

// lookbackwardsCount is how far back to look in a log for problems. This should be large enough to
Expand Down Expand Up @@ -105,14 +106,21 @@ func OutputProblems(problems map[string][]string, maxLines int) {
// Output displays logs from multiple sources in tail(1) format
func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, runner bootstrapper.CommandRunner, lines int) error {
cmds := logCommands(r, bs, lines, false)

// These are not technically logs, but are useful to have in bug reports.
cmds["kernel"] = "uptime && uname -a"

names := []string{}
for k := range cmds {
names = append(names, k)
}
sort.Strings(names)

failed := []string{}
for _, name := range names {
for i, name := range names {
if i > 0 {
console.OutLn("")
}
console.OutLn("==> %s <==", name)
var b bytes.Buffer
err := runner.CombinedOutputTo(cmds[name], &b)
Expand Down

0 comments on commit 7f6eeca

Please sign in to comment.