@@ -16,6 +16,7 @@ import (
1616 . "github.com/onsi/ginkgo/v2"
1717 . "github.com/onsi/gomega"
1818
19+ corev1 "k8s.io/api/core/v1"
1920 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2021)
2122
@@ -36,6 +37,26 @@ var _ = Describe("[Admin API] ETCD key count action", func() {
3637 )
3738 Expect (nodes .Items ).NotTo (BeEmpty (), "expected at least one master node" )
3839 vmName := nodes .Items [0 ].Name
40+ podName := "etcd-" + vmName
41+
42+ By ("verifying the etcd pod is ready before attempting to exec" )
43+ Eventually (func (g Gomega , ctx context.Context ) {
44+ pod := GetK8sObjectWithRetry (
45+ ctx , clients .Kubernetes .CoreV1 ().Pods ("openshift-etcd" ).Get , podName , metav1.GetOptions {},
46+ )
47+ g .Expect (pod .Status .Phase ).To (Equal (corev1 .PodRunning ),
48+ "pod %s phase: expected Running, got %s" , podName , pod .Status .Phase )
49+ // Verify pod is actually ready (not just Running)
50+ for _ , cond := range pod .Status .Conditions {
51+ if cond .Type == corev1 .PodReady {
52+ g .Expect (cond .Status ).To (Equal (corev1 .ConditionTrue ),
53+ "pod %s Ready condition: expected True, got %s" , podName , cond .Status )
54+ return
55+ }
56+ }
57+ g .Expect (false ).To (BeTrue (), "pod %s has no Ready condition" , podName )
58+ }).WithContext (ctx ).WithTimeout (DefaultEventuallyTimeout ).Should (Succeed (),
59+ "etcd pod %s not ready within timeout" , podName )
3960
4061 By ("calling the etcdkeycount admin API with vmName=" + vmName )
4162 params := url.Values {"vmName" : []string {vmName }}
0 commit comments