From e6d6d8e14c2764586d080ac97b18a5dfbad730ae Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 25 Feb 2024 07:25:58 +0800 Subject: [PATCH] feat: print etcd ready status Signed-off-by: yxxhero --- cmd/kubeadm/app/util/etcd/etcd.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/kubeadm/app/util/etcd/etcd.go b/cmd/kubeadm/app/util/etcd/etcd.go index d037d263a30..597fd0fa262 100644 --- a/cmd/kubeadm/app/util/etcd/etcd.go +++ b/cmd/kubeadm/app/util/etcd/etcd.go @@ -34,6 +34,7 @@ import ( clientv3 "go.etcd.io/etcd/client/v3" "google.golang.org/grpc" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" @@ -229,6 +230,16 @@ func getRawEtcdEndpointsFromPodAnnotationWithoutRetry(client clientset.Interface } etcdEndpoints := []string{} for _, pod := range podList.Items { + podIsReady := false + for _, c := range pod.Status.Conditions { + if c.Type == corev1.PodReady && c.Status == corev1.ConditionTrue { + podIsReady = true + break + } + } + if !podIsReady { + klog.V(3).Infof("etcd pod %q is not ready", pod.ObjectMeta.Name) + } etcdEndpoint, ok := pod.ObjectMeta.Annotations[constants.EtcdAdvertiseClientUrlsAnnotationKey] if !ok { klog.V(3).Infof("etcd Pod %q is missing the %q annotation; cannot infer etcd advertise client URL using the Pod annotation", pod.ObjectMeta.Name, constants.EtcdAdvertiseClientUrlsAnnotationKey)