@@ -76,7 +76,8 @@ func WaitForSystemPods(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg con
76
76
}
77
77
78
78
// ExpectAppsRunning returns whether or not all expected k8s-apps are running. (without waiting for them)
79
- func ExpectAppsRunning (cs * kubernetes.Clientset , expected []string ) error {
79
+ func ExpectAppsRunning (cfg * config.ClusterConfig , cs * kubernetes.Clientset , expected []string ) error {
80
+
80
81
found := map [string ]bool {}
81
82
82
83
pods , err := cs .CoreV1 ().Pods ("kube-system" ).List (context .Background (), meta.ListOptions {})
@@ -85,12 +86,32 @@ func ExpectAppsRunning(cs *kubernetes.Clientset, expected []string) error {
85
86
}
86
87
klog .Infof ("%d kube-system pods found" , len (pods .Items ))
87
88
89
+ for ! config .IsHA (* cfg ) && ! cfg .DisableOptimizations {
90
+ // when --disable-optimization is not specified
91
+ // for non-HA cluster
92
+ // core dns deployment has been scaled to 1 pods, wait until there is only 1 pod
93
+ corednsPods , err := cs .CoreV1 ().Pods ("kube-system" ).List (context .Background (), meta.ListOptions {
94
+ LabelSelector : "k8s-app=kube-dns" ,
95
+ })
96
+ if err != nil {
97
+ return err
98
+ }
99
+ if len (corednsPods .Items ) == 1 {
100
+ break
101
+ }
102
+ }
103
+
88
104
for _ , pod := range pods .Items {
89
105
klog .Info (podStatusMsg (pod ))
90
106
91
107
if pod .Status .Phase != core .PodRunning {
92
108
continue
93
109
}
110
+ for _ , cs := range pod .Status .ContainerStatuses {
111
+ if ! cs .Ready {
112
+ continue
113
+ }
114
+ }
94
115
95
116
for k , v := range pod .ObjectMeta .Labels {
96
117
if k == "component" || k == "k8s-app" {
@@ -112,12 +133,12 @@ func ExpectAppsRunning(cs *kubernetes.Clientset, expected []string) error {
112
133
}
113
134
114
135
// WaitForAppsRunning waits for expected Apps To be running
115
- func WaitForAppsRunning (cs * kubernetes.Clientset , expected []string , timeout time.Duration ) error {
136
+ func WaitForAppsRunning (cfg * config. ClusterConfig , cs * kubernetes.Clientset , expected []string , timeout time.Duration ) error {
116
137
klog .Info ("waiting for k8s-apps to be running ..." )
117
138
start := time .Now ()
118
139
119
140
checkRunning := func () error {
120
- return ExpectAppsRunning (cs , expected )
141
+ return ExpectAppsRunning (cfg , cs , expected )
121
142
}
122
143
123
144
if err := retry .Local (checkRunning , timeout ); err != nil {
0 commit comments