Revert "fix --wait's failure to work on coredns pods (#19748)"

This reverts commit 3fef3ea0ac.
pull/20313/head
Predrag Rogic 2025-01-25 22:43:49 +00:00 committed by GitHub
parent 9bb6e238c7
commit aee8aad812
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 25 deletions

View File

@ -76,8 +76,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(cfg *config.ClusterConfig, cs *kubernetes.Clientset, expected []string) error {
func ExpectAppsRunning(cs *kubernetes.Clientset, expected []string) error {
found := map[string]bool{}
pods, err := cs.CoreV1().Pods("kube-system").List(context.Background(), meta.ListOptions{})
@ -86,32 +85,12 @@ func ExpectAppsRunning(cfg *config.ClusterConfig, cs *kubernetes.Clientset, expe
}
klog.Infof("%d kube-system pods found", len(pods.Items))
for !config.IsHA(*cfg) && !cfg.DisableOptimizations {
// when --disable-optimization is not specified
// for non-HA cluster
// 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" {
@ -133,12 +112,12 @@ func ExpectAppsRunning(cfg *config.ClusterConfig, cs *kubernetes.Clientset, expe
}
// WaitForAppsRunning waits for expected Apps To be running
func WaitForAppsRunning(cfg *config.ClusterConfig, cs *kubernetes.Clientset, expected []string, timeout time.Duration) error {
func WaitForAppsRunning(cs *kubernetes.Clientset, expected []string, timeout time.Duration) error {
klog.Info("waiting for k8s-apps to be running ...")
start := time.Now()
checkRunning := func() error {
return ExpectAppsRunning(cfg, cs, expected)
return ExpectAppsRunning(cs, expected)
}
if err := retry.Local(checkRunning, timeout); err != nil {

View File

@ -567,7 +567,7 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
}
if cfg.VerifyComponents[kverify.AppsRunningKey] {
if err := kverify.WaitForAppsRunning(&cfg, client, kverify.AppsRunningList, timeout); err != nil {
if err := kverify.WaitForAppsRunning(client, kverify.AppsRunningList, timeout); err != nil {
return errors.Wrap(err, "waiting for apps_running")
}
}