@@ -355,7 +355,7 @@ func (k *Bootstrapper) client(ip string, port int) (*kubernetes.Clientset, error
355
355
}
356
356
357
357
// WaitForNode blocks until the node appears to be healthy
358
- func (k * Bootstrapper ) WaitForNode (cfg config.ClusterConfig , n config.Node , timeout time.Duration ) ( waitErr error ) {
358
+ func (k * Bootstrapper ) WaitForNode (cfg config.ClusterConfig , n config.Node , timeout time.Duration ) error {
359
359
start := time .Now ()
360
360
361
361
if ! n .ControlPlane {
@@ -371,20 +371,19 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
371
371
return errors .Wrap (err , "get control plane endpoint" )
372
372
}
373
373
374
- defer func () { // run pressure verification after all other checks, so there be an api server to talk to.
375
- client , err := k .client (hostname , port )
376
- if err != nil {
377
- waitErr = errors .Wrap (err , "get k8s client" )
378
- }
379
- if err := kverify .NodePressure (client ); err != nil {
380
- adviseNodePressure (err , cfg .Name , cfg .Driver )
381
- waitErr = errors .Wrap (err , "node pressure" )
382
- }
383
- }()
374
+ client , err := k .client (hostname , port )
375
+ if err != nil {
376
+ return errors .Wrap (err , "kubernetes client" )
377
+ }
384
378
385
379
if ! kverify .ShouldWait (cfg .VerifyComponents ) {
386
380
glog .Infof ("skip waiting for components based on config." )
387
- return waitErr
381
+
382
+ if err := kverify .NodePressure (client ); err != nil {
383
+ adviseNodePressure (err , cfg .Name , cfg .Driver )
384
+ return errors .Wrap (err , "node pressure" )
385
+ }
386
+ return nil
388
387
}
389
388
390
389
cr , err := cruntime .New (cruntime.Config {Type : cfg .KubernetesConfig .ContainerRuntime , Runner : k .c })
@@ -393,10 +392,6 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
393
392
}
394
393
395
394
if cfg .VerifyComponents [kverify .APIServerWaitKey ] {
396
- client , err := k .client (hostname , port )
397
- if err != nil {
398
- return errors .Wrap (err , "get k8s client" )
399
- }
400
395
if err := kverify .WaitForAPIServerProcess (cr , k , cfg , k .c , start , timeout ); err != nil {
401
396
return errors .Wrap (err , "wait for apiserver proc" )
402
397
}
@@ -407,47 +402,36 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
407
402
}
408
403
409
404
if cfg .VerifyComponents [kverify .SystemPodsWaitKey ] {
410
- client , err := k .client (hostname , port )
411
- if err != nil {
412
- return errors .Wrap (err , "get k8s client" )
413
- }
414
405
if err := kverify .WaitForSystemPods (cr , k , cfg , k .c , client , start , timeout ); err != nil {
415
406
return errors .Wrap (err , "waiting for system pods" )
416
407
}
417
408
}
418
409
419
410
if cfg .VerifyComponents [kverify .DefaultSAWaitKey ] {
420
- client , err := k .client (hostname , port )
421
- if err != nil {
422
- return errors .Wrap (err , "get k8s client" )
423
- }
424
411
if err := kverify .WaitForDefaultSA (client , timeout ); err != nil {
425
412
return errors .Wrap (err , "waiting for default service account" )
426
413
}
427
414
}
428
415
429
416
if cfg .VerifyComponents [kverify .AppsRunningKey ] {
430
- client , err := k .client (hostname , port )
431
- if err != nil {
432
- return errors .Wrap (err , "get k8s client" )
433
- }
434
417
if err := kverify .WaitForAppsRunning (client , kverify .AppsRunningList , timeout ); err != nil {
435
418
return errors .Wrap (err , "waiting for apps_running" )
436
419
}
437
420
}
438
421
439
422
if cfg .VerifyComponents [kverify .NodeReadyKey ] {
440
- client , err := k .client (hostname , port )
441
- if err != nil {
442
- return errors .Wrap (err , "get k8s client" )
443
- }
444
423
if err := kverify .WaitForNodeReady (client , timeout ); err != nil {
445
424
return errors .Wrap (err , "waiting for node to be ready" )
446
425
}
447
426
}
448
427
449
428
glog .Infof ("duration metric: took %s to wait for : %+v ..." , time .Since (start ), cfg .VerifyComponents )
450
- return waitErr
429
+
430
+ if err := kverify .NodePressure (client ); err != nil {
431
+ adviseNodePressure (err , cfg .Name , cfg .Driver )
432
+ return errors .Wrap (err , "node pressure" )
433
+ }
434
+ return nil
451
435
}
452
436
453
437
// needsReconfigure returns whether or not the cluster needs to be reconfigured
0 commit comments