Reorder conditions in FindMatchingVolume to avoid checking NodeAffinity

in trivial cases.
This commit is contained in:
Maciej Borsz
2020-02-25 16:26:26 +01:00
parent b6b494b448
commit 7d59ea8394
2 changed files with 19 additions and 19 deletions

View File

@@ -1385,12 +1385,11 @@ func CreatePodWithPersistentVolume(client clientset.Interface, namespace string,
createError = fmt.Errorf("error creating PV: %s", err)
return
}
// We need to update status separately, as creating persistentvolumes resets status to the default one
// (so with Status.Phase will be equal to PersistentVolumePhase).
// We need to update statuses separately, as creating pv/pvc resets status to the default one.
if _, err := client.CoreV1().PersistentVolumes().UpdateStatus(context.TODO(), pv, metav1.UpdateOptions{}); err != nil {
lock.Lock()
defer lock.Unlock()
createError = fmt.Errorf("error creating PV: %s", err)
createError = fmt.Errorf("error updating PV status: %s", err)
return
}
@@ -1400,6 +1399,12 @@ func CreatePodWithPersistentVolume(client clientset.Interface, namespace string,
createError = fmt.Errorf("error creating PVC: %s", err)
return
}
if _, err := client.CoreV1().PersistentVolumeClaims(namespace).UpdateStatus(context.TODO(), pvc, metav1.UpdateOptions{}); err != nil {
lock.Lock()
defer lock.Unlock()
createError = fmt.Errorf("error updating PVC status: %s", err)
return
}
// pod
pod := podTemplate.DeepCopy()