From 5ccd0c4f8196c54cf31dd6a7ca8e5b470a842237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= Date: Thu, 3 Oct 2024 22:44:07 +0200 Subject: [PATCH] fix --wait's failure to work on coredns pods --- .../bsutil/kverify/system_pods.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go b/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go index 7da7512312db..67316f1010c8 100644 --- a/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go +++ b/pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go @@ -77,6 +77,7 @@ func WaitForSystemPods(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg con // ExpectAppsRunning returns whether or not all expected k8s-apps are running. (without waiting for them) func ExpectAppsRunning(cs *kubernetes.Clientset, expected []string) error { + found := map[string]bool{} pods, err := cs.CoreV1().Pods("kube-system").List(context.Background(), meta.ListOptions{}) @@ -85,12 +86,30 @@ func ExpectAppsRunning(cs *kubernetes.Clientset, expected []string) error { } klog.Infof("%d kube-system pods found", len(pods.Items)) + for { + // core dns deployment has been scaled to 1 pods, wait until there is only 1 pod + corednsPods, err := cs.CoreV1().Pods("kube-system").List(context.Background(), meta.ListOptions{ + LabelSelector: "k8s-app=kube-dns", + }) + if err != nil { + return err + } + if len(corednsPods.Items) == 1 { + break + } + } + for _, pod := range pods.Items { klog.Info(podStatusMsg(pod)) if pod.Status.Phase != core.PodRunning { continue } + for _, cs := range pod.Status.ContainerStatuses { + if !cs.Ready { + continue + } + } for k, v := range pod.ObjectMeta.Labels { if k == "component" || k == "k8s-app" {