@@ -111,51 +111,35 @@ func deleteNamespace(c kubernetes.Interface, name string) error {
111111// Ready blocks until the cluster is considered available. The current
112112// implementation checks that 1 schedulable node is ready.
113113func ready (c kubernetes.Interface ) error {
114- f := func () error {
114+ return retry ( 50 , 10 * time . Second , func () error {
115115 list , err := c .CoreV1 ().Nodes ().List (metav1.ListOptions {})
116116 if err != nil {
117- return err
117+ return fmt . Errorf ( "error listing nodes: %v" , err )
118118 }
119119
120120 if len (list .Items ) < 1 {
121- return fmt .Errorf ("cluster is not ready, waiting for 1 or more worker nodes: %v" , len (list .Items ))
121+ return fmt .Errorf ("cluster is not ready, waiting for 1 or more worker nodes, have %v" , len (list .Items ))
122122 }
123123
124- // check for 1 or more ready nodes by ignoring nodes marked
125- // unschedulable or containing taints
126- var oneReady bool
124+ // check for 1 or more ready nodes by ignoring nodes marked unschedulable or containing taints
127125 for _ , node := range list .Items {
128- if node .Spec .Unschedulable {
129- log .Println ("no worker nodes checked in yet" )
130- continue
131- }
132-
133- if len (node .Spec .Taints ) != 0 {
134- log .Println ("no worker nodes checked in yet" )
135- continue
136- }
137-
138- for _ , condition := range node .Status .Conditions {
139- if condition .Type == v1 .NodeReady {
140- if condition .Status == v1 .ConditionTrue {
141- oneReady = true
126+ switch {
127+ case node .Spec .Unschedulable :
128+ log .Printf ("worker node %q is unschedulable\n " , node .Name )
129+ case len (node .Spec .Taints ) != 0 :
130+ log .Printf ("worker node %q is tainted\n " , node .Name )
131+ default :
132+ for _ , condition := range node .Status .Conditions {
133+ if condition .Type == v1 .NodeReady && condition .Status == v1 .ConditionTrue {
134+ log .Printf ("worker node %q is ready\n " , node .Name )
135+ return nil
142136 }
143- log .Println ("waiting for first worker to be ready" )
144- break
145137 }
138+ log .Printf ("worker node %q is not ready\n " , node .Name )
146139 }
147140 }
148- if ! oneReady {
149- return fmt .Errorf ("waiting for one worker node to be ready" )
150- }
151-
152- return nil
153- }
154-
155- if err := retry (50 , 10 * time .Second , f ); err != nil {
156- return err
157- }
158- return nil
141+ return fmt .Errorf ("no worker nodes are ready, will retry" )
142+ })
159143}
160144
161145func retry (attempts int , delay time.Duration , f func () error ) error {
0 commit comments