@@ -882,13 +882,12 @@ func WaitForPersistentVolumePhase(phase v1.PersistentVolumePhase, c clientset.In
882
882
if err != nil {
883
883
Logf ("Get persistent volume %s in failed, ignoring for %v: %v" , pvName , Poll , err )
884
884
continue
885
- } else {
886
- if pv .Status .Phase == phase {
887
- Logf ("PersistentVolume %s found and phase=%s (%v)" , pvName , phase , time .Since (start ))
888
- return nil
889
- }
890
- Logf ("PersistentVolume %s found but phase is %s instead of %s." , pvName , pv .Status .Phase , phase )
891
885
}
886
+ if pv .Status .Phase == phase {
887
+ Logf ("PersistentVolume %s found and phase=%s (%v)" , pvName , phase , time .Since (start ))
888
+ return nil
889
+ }
890
+ Logf ("PersistentVolume %s found but phase is %s instead of %s." , pvName , pv .Status .Phase , phase )
892
891
}
893
892
return fmt .Errorf ("PersistentVolume %s not in phase %s within %v" , pvName , phase , timeout )
894
893
}
@@ -901,13 +900,12 @@ func WaitForStatefulSetReplicasReady(statefulSetName, ns string, c clientset.Int
901
900
if err != nil {
902
901
Logf ("Get StatefulSet %s failed, ignoring for %v: %v" , statefulSetName , Poll , err )
903
902
continue
904
- } else {
905
- if sts .Status .ReadyReplicas == * sts .Spec .Replicas {
906
- Logf ("All %d replicas of StatefulSet %s are ready. (%v)" , sts .Status .ReadyReplicas , statefulSetName , time .Since (start ))
907
- return nil
908
- }
909
- Logf ("StatefulSet %s found but there are %d ready replicas and %d total replicas." , statefulSetName , sts .Status .ReadyReplicas , * sts .Spec .Replicas )
910
903
}
904
+ if sts .Status .ReadyReplicas == * sts .Spec .Replicas {
905
+ Logf ("All %d replicas of StatefulSet %s are ready. (%v)" , sts .Status .ReadyReplicas , statefulSetName , time .Since (start ))
906
+ return nil
907
+ }
908
+ Logf ("StatefulSet %s found but there are %d ready replicas and %d total replicas." , statefulSetName , sts .Status .ReadyReplicas , * sts .Spec .Replicas )
911
909
}
912
910
return fmt .Errorf ("StatefulSet %s still has unready pods within %v" , statefulSetName , timeout )
913
911
}
@@ -920,13 +918,12 @@ func WaitForPersistentVolumeDeleted(c clientset.Interface, pvName string, Poll,
920
918
if err == nil {
921
919
Logf ("PersistentVolume %s found and phase=%s (%v)" , pvName , pv .Status .Phase , time .Since (start ))
922
920
continue
923
- } else {
924
- if apierrs .IsNotFound (err ) {
925
- Logf ("PersistentVolume %s was removed" , pvName )
926
- return nil
927
- }
928
- Logf ("Get persistent volume %s in failed, ignoring for %v: %v" , pvName , Poll , err )
929
921
}
922
+ if apierrs .IsNotFound (err ) {
923
+ Logf ("PersistentVolume %s was removed" , pvName )
924
+ return nil
925
+ }
926
+ Logf ("Get persistent volume %s in failed, ignoring for %v: %v" , pvName , Poll , err )
930
927
}
931
928
return fmt .Errorf ("PersistentVolume %s still exists within %v" , pvName , timeout )
932
929
}
@@ -950,16 +947,15 @@ func WaitForPersistentVolumeClaimsPhase(phase v1.PersistentVolumeClaimPhase, c c
950
947
if err != nil {
951
948
Logf ("Failed to get claim %q, retrying in %v. Error: %v" , pvcName , Poll , err )
952
949
continue
953
- } else {
954
- if pvc .Status .Phase == phase {
955
- Logf ("PersistentVolumeClaim %s found and phase=%s (%v)" , pvcName , phase , time .Since (start ))
956
- if matchAny {
957
- return nil
958
- }
959
- } else {
960
- Logf ("PersistentVolumeClaim %s found but phase is %s instead of %s." , pvcName , pvc .Status .Phase , phase )
961
- phaseFoundInAllClaims = false
950
+ }
951
+ if pvc .Status .Phase == phase {
952
+ Logf ("PersistentVolumeClaim %s found and phase=%s (%v)" , pvcName , phase , time .Since (start ))
953
+ if matchAny {
954
+ return nil
962
955
}
956
+ } else {
957
+ Logf ("PersistentVolumeClaim %s found but phase is %s instead of %s." , pvcName , pvc .Status .Phase , phase )
958
+ phaseFoundInAllClaims = false
963
959
}
964
960
}
965
961
if phaseFoundInAllClaims {
@@ -3513,41 +3509,37 @@ func isNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionT
3513
3509
if wantTrue {
3514
3510
if (cond .Status == v1 .ConditionTrue ) && ! hasNodeControllerTaints {
3515
3511
return true
3516
- } else {
3517
- msg := ""
3518
- if ! hasNodeControllerTaints {
3519
- msg = fmt .Sprintf ("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v" ,
3520
- conditionType , node .Name , cond .Status == v1 .ConditionTrue , wantTrue , cond .Reason , cond .Message )
3521
- } else {
3522
- msg = fmt .Sprintf ("Condition %s of node %s is %v, but Node is tainted by NodeController with %v. Failure" ,
3523
- conditionType , node .Name , cond .Status == v1 .ConditionTrue , taints )
3524
- }
3525
- if ! silent {
3526
- Logf (msg )
3527
- }
3528
- return false
3529
3512
}
3530
- } else {
3531
- // TODO: check if the Node is tainted once we enable NC notReady/unreachable taints by default
3532
- if cond . Status != v1 . ConditionTrue {
3533
- return true
3513
+ msg := ""
3514
+ if ! hasNodeControllerTaints {
3515
+ msg = fmt . Sprintf ( "Condition %s of node %s is %v instead of %t. Reason: %v, message: %v" ,
3516
+ conditionType , node . Name , cond . Status == v1 . ConditionTrue , wantTrue , cond . Reason , cond . Message )
3534
3517
}
3518
+ msg = fmt .Sprintf ("Condition %s of node %s is %v, but Node is tainted by NodeController with %v. Failure" ,
3519
+ conditionType , node .Name , cond .Status == v1 .ConditionTrue , taints )
3535
3520
if ! silent {
3536
- Logf ("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v" ,
3537
- conditionType , node .Name , cond .Status == v1 .ConditionTrue , wantTrue , cond .Reason , cond .Message )
3521
+ Logf (msg )
3538
3522
}
3539
3523
return false
3540
3524
}
3541
- }
3542
- if ( wantTrue && ( cond .Status == v1 . ConditionTrue )) || ( ! wantTrue && ( cond . Status ! = v1 .ConditionTrue )) {
3543
- return true
3544
- } else {
3525
+ // TODO: check if the Node is tainted once we enable NC notReady/unreachable taints by default
3526
+ if cond .Status ! = v1 .ConditionTrue {
3527
+ return true
3528
+ }
3545
3529
if ! silent {
3546
3530
Logf ("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v" ,
3547
3531
conditionType , node .Name , cond .Status == v1 .ConditionTrue , wantTrue , cond .Reason , cond .Message )
3548
3532
}
3549
3533
return false
3550
3534
}
3535
+ if (wantTrue && (cond .Status == v1 .ConditionTrue )) || (! wantTrue && (cond .Status != v1 .ConditionTrue )) {
3536
+ return true
3537
+ }
3538
+ if ! silent {
3539
+ Logf ("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v" ,
3540
+ conditionType , node .Name , cond .Status == v1 .ConditionTrue , wantTrue , cond .Reason , cond .Message )
3541
+ }
3542
+ return false
3551
3543
}
3552
3544
3553
3545
}
0 commit comments