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

Add ingress pod to logs output #15775

Merged
merged 4 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
23 changes: 18 additions & 5 deletions pkg/minikube/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ var importantPods = []string{
"coredns",
"kube-scheduler",
"kube-proxy",
"kubernetes-dashboard",
"storage-provisioner",
"kube-controller-manager",
}

Expand Down Expand Up @@ -267,9 +265,8 @@ func OutputOffline(lines int, logOutput *os.File) {
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})
pods := importantPods
if assets.Addons["gcp-auth"].IsEnabled(&cfg) {
pods = append(pods, "gcp-auth")
}
addonPods := enabledAddonPods(cfg)
pods = append(pods, addonPods...)
for _, pod := range pods {
ids, err := r.ListContainers(cruntime.ListContainersOptions{Name: pod})
if err != nil {
Expand All @@ -291,3 +288,19 @@ func logCommands(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cl

return cmds
}

func enabledAddonPods(cfg config.ClusterConfig) []string {
addonPodMap := map[string]string{
"dashboard": "kubernetes-dashboard",
"gcp-auth": "gcp-auth",
"ingress": "controller_ingress",
"storage-provisioner": "storage-provisioner",
}
addonsPods := []string{}
for addon, podName := range addonPodMap {
if assets.Addons[addon].IsEnabled(&cfg) {
addonsPods = append(addonsPods, podName)
}
}
return addonsPods
}
28 changes: 28 additions & 0 deletions pkg/minikube/logs/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package logs

import (
"testing"

"k8s.io/minikube/pkg/minikube/config"
)

func TestIsProblem(t *testing.T) {
Expand Down Expand Up @@ -61,3 +63,29 @@ func TestIsProblem(t *testing.T) {
})
}
}

func TestEnabledAddonPods(t *testing.T) {
cfg := config.ClusterConfig{
Addons: map[string]bool{
"dashboard": true,
"gcp-auth": true,
"ingress": true,
"storage-provisioner": true,
},
}

got := enabledAddonPods(cfg)
expectedPods := []string{"kubernetes-dashboard", "gcp-auth", "controller_ingress", "storage-provisioner"}
for _, expectedPod := range expectedPods {
found := false
for _, pod := range got {
if expectedPod == pod {
found = true
break
}
}
if !found {
t.Errorf("%q was not found; got = %s", expectedPod, got)
}
}
}