mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #77481 from danielqsj/fu
remove redundant else block
This commit is contained in:
commit
ad57e7408d
@ -882,13 +882,12 @@ 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 {
|
|
||||||
Logf("PersistentVolume %s found and phase=%s (%v)", pvName, phase, time.Since(start))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
Logf("PersistentVolume %s found but phase is %s instead of %s.", pvName, pv.Status.Phase, phase)
|
|
||||||
}
|
}
|
||||||
|
if pv.Status.Phase == phase {
|
||||||
|
Logf("PersistentVolume %s found and phase=%s (%v)", pvName, phase, time.Since(start))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
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,13 +900,12 @@ 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 {
|
|
||||||
Logf("All %d replicas of StatefulSet %s are ready. (%v)", sts.Status.ReadyReplicas, statefulSetName, time.Since(start))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
Logf("StatefulSet %s found but there are %d ready replicas and %d total replicas.", statefulSetName, 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))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
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,13 +918,12 @@ 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) {
|
|
||||||
Logf("PersistentVolume %s was removed", pvName)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
Logf("Get persistent volume %s in failed, ignoring for %v: %v", pvName, Poll, err)
|
|
||||||
}
|
}
|
||||||
|
if apierrs.IsNotFound(err) {
|
||||||
|
Logf("PersistentVolume %s was removed", pvName)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
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,16 +947,15 @@ 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 {
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Logf("PersistentVolumeClaim %s found but phase is %s instead of %s.", pvcName, pvc.Status.Phase, phase)
|
|
||||||
phaseFoundInAllClaims = false
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Logf("PersistentVolumeClaim %s found but phase is %s instead of %s.", pvcName, pvc.Status.Phase, phase)
|
||||||
|
phaseFoundInAllClaims = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if phaseFoundInAllClaims {
|
if phaseFoundInAllClaims {
|
||||||
@ -3513,41 +3509,37 @@ 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 := ""
|
|
||||||
if !hasNodeControllerTaints {
|
|
||||||
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)
|
|
||||||
} else {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
if !silent {
|
|
||||||
Logf(msg)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
} else {
|
msg := ""
|
||||||
// TODO: check if the Node is tainted once we enable NC notReady/unreachable taints by default
|
if !hasNodeControllerTaints {
|
||||||
if cond.Status != v1.ConditionTrue {
|
msg = fmt.Sprintf("Condition %s of node %s is %v instead of %t. Reason: %v, message: %v",
|
||||||
return true
|
|
||||||
}
|
|
||||||
if !silent {
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
if !silent {
|
||||||
|
Logf(msg)
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
// TODO: check if the Node is tainted once we enable NC notReady/unreachable taints by default
|
||||||
if (wantTrue && (cond.Status == v1.ConditionTrue)) || (!wantTrue && (cond.Status != v1.ConditionTrue)) {
|
if 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 (wantTrue && (cond.Status == v1.ConditionTrue)) || (!wantTrue && (cond.Status != v1.ConditionTrue)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if !silent {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user