Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logs: Add kube-proxy, dmesg, uptime, uname + newlines between log sources #3872

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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