Merge pull request #77481 from danielqsj/fu

remove redundant else block
This commit is contained in:
Kubernetes Prow Robot 2019-05-06 06:53:53 -07:00 committed by GitHub
commit ad57e7408d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -882,14 +882,13 @@ func WaitForPersistentVolumePhase(phase v1.PersistentVolumePhase, c clientset.In
if err != nil { if err != nil {
Logf("Get persistent volume %s in failed, ignoring for %v: %v", pvName, Poll, err) Logf("Get persistent volume %s in failed, ignoring for %v: %v", pvName, Poll, err)
continue continue
} else { }
if pv.Status.Phase == phase { if pv.Status.Phase == phase {
Logf("PersistentVolume %s found and phase=%s (%v)", pvName, phase, time.Since(start)) Logf("PersistentVolume %s found and phase=%s (%v)", pvName, phase, time.Since(start))
return nil return nil
} }
Logf("PersistentVolume %s found but phase is %s instead of %s.", pvName, pv.Status.Phase, phase) Logf("PersistentVolume %s found but phase is %s instead of %s.", pvName, pv.Status.Phase, phase)
} }
}
return fmt.Errorf("PersistentVolume %s not in phase %s within %v", pvName, phase, timeout) return fmt.Errorf("PersistentVolume %s not in phase %s within %v", pvName, phase, timeout)
} }
@ -901,14 +900,13 @@ func WaitForStatefulSetReplicasReady(statefulSetName, ns string, c clientset.Int
if err != nil { if err != nil {
Logf("Get StatefulSet %s failed, ignoring for %v: %v", statefulSetName, Poll, err) Logf("Get StatefulSet %s failed, ignoring for %v: %v", statefulSetName, Poll, err)
continue continue
} else { }
if sts.Status.ReadyReplicas == *sts.Spec.Replicas { if sts.Status.ReadyReplicas == *sts.Spec.Replicas {
Logf("All %d replicas of StatefulSet %s are ready. (%v)", sts.Status.ReadyReplicas, statefulSetName, time.Since(start)) Logf("All %d replicas of StatefulSet %s are ready. (%v)", sts.Status.ReadyReplicas, statefulSetName, time.Since(start))
return nil return nil
} }
Logf("StatefulSet %s found but there are %d ready replicas and %d total replicas.", statefulSetName, sts.Status.ReadyReplicas, *sts.Spec.Replicas) Logf("StatefulSet %s found but there are %d ready replicas and %d total replicas.", statefulSetName, sts.Status.ReadyReplicas, *sts.Spec.Replicas)
} }
}
return fmt.Errorf("StatefulSet %s still has unready pods within %v", statefulSetName, timeout) return fmt.Errorf("StatefulSet %s still has unready pods within %v", statefulSetName, timeout)
} }
@ -920,14 +918,13 @@ func WaitForPersistentVolumeDeleted(c clientset.Interface, pvName string, Poll,
if err == nil { if err == nil {
Logf("PersistentVolume %s found and phase=%s (%v)", pvName, pv.Status.Phase, time.Since(start)) Logf("PersistentVolume %s found and phase=%s (%v)", pvName, pv.Status.Phase, time.Since(start))
continue continue
} else { }
if apierrs.IsNotFound(err) { if apierrs.IsNotFound(err) {
Logf("PersistentVolume %s was removed", pvName) Logf("PersistentVolume %s was removed", pvName)
return nil return nil
} }
Logf("Get persistent volume %s in failed, ignoring for %v: %v", pvName, Poll, err) Logf("Get persistent volume %s in failed, ignoring for %v: %v", pvName, Poll, err)
} }
}
return fmt.Errorf("PersistentVolume %s still exists within %v", pvName, timeout) return fmt.Errorf("PersistentVolume %s still exists within %v", pvName, timeout)
} }
@ -950,7 +947,7 @@ func WaitForPersistentVolumeClaimsPhase(phase v1.PersistentVolumeClaimPhase, c c
if err != nil { if err != nil {
Logf("Failed to get claim %q, retrying in %v. Error: %v", pvcName, Poll, err) Logf("Failed to get claim %q, retrying in %v. Error: %v", pvcName, Poll, err)
continue continue
} else { }
if pvc.Status.Phase == phase { if pvc.Status.Phase == phase {
Logf("PersistentVolumeClaim %s found and phase=%s (%v)", pvcName, phase, time.Since(start)) Logf("PersistentVolumeClaim %s found and phase=%s (%v)", pvcName, phase, time.Since(start))
if matchAny { if matchAny {
@ -961,7 +958,6 @@ func WaitForPersistentVolumeClaimsPhase(phase v1.PersistentVolumeClaimPhase, c c
phaseFoundInAllClaims = false phaseFoundInAllClaims = false
} }
} }
}
if phaseFoundInAllClaims { if phaseFoundInAllClaims {
return nil return nil
} }
@ -3513,21 +3509,19 @@ func isNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionT
if wantTrue { if wantTrue {
if (cond.Status == v1.ConditionTrue) && !hasNodeControllerTaints { if (cond.Status == v1.ConditionTrue) && !hasNodeControllerTaints {
return true return true
} else { }
msg := "" msg := ""
if !hasNodeControllerTaints { if !hasNodeControllerTaints {
msg = fmt.Sprintf("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v", msg = fmt.Sprintf("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v",
conditionType, node.Name, cond.Status == v1.ConditionTrue, wantTrue, cond.Reason, cond.Message) conditionType, node.Name, cond.Status == v1.ConditionTrue, wantTrue, cond.Reason, cond.Message)
} else { }
msg = fmt.Sprintf("Condition %s of node %s is %v, but Node is tainted by NodeController with %v. Failure", msg = fmt.Sprintf("Condition %s of node %s is %v, but Node is tainted by NodeController with %v. Failure",
conditionType, node.Name, cond.Status == v1.ConditionTrue, taints) conditionType, node.Name, cond.Status == v1.ConditionTrue, taints)
}
if !silent { if !silent {
Logf(msg) Logf(msg)
} }
return false return false
} }
} else {
// TODO: check if the Node is tainted once we enable NC notReady/unreachable taints by default // TODO: check if the Node is tainted once we enable NC notReady/unreachable taints by default
if cond.Status != v1.ConditionTrue { if cond.Status != v1.ConditionTrue {
return true return true
@ -3538,17 +3532,15 @@ func isNodeConditionSetAsExpected(node *v1.Node, conditionType v1.NodeConditionT
} }
return false return false
} }
}
if (wantTrue && (cond.Status == v1.ConditionTrue)) || (!wantTrue && (cond.Status != v1.ConditionTrue)) { if (wantTrue && (cond.Status == v1.ConditionTrue)) || (!wantTrue && (cond.Status != v1.ConditionTrue)) {
return true return true
} else { }
if !silent { if !silent {
Logf("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v", Logf("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v",
conditionType, node.Name, cond.Status == v1.ConditionTrue, wantTrue, cond.Reason, cond.Message) conditionType, node.Name, cond.Status == v1.ConditionTrue, wantTrue, cond.Reason, cond.Message)
} }
return false return false
} }
}
} }
if !silent { if !silent {