mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
fix_review_comments
This commit is contained in:
parent
3f3ce8659f
commit
e93016b68c
@ -317,8 +317,8 @@ func (pl *VolumeZone) isSchedulableAfterPersistentVolumeClaimChange(logger klog.
|
||||
if err != nil {
|
||||
return framework.Queue, fmt.Errorf("unexpected objects in isSchedulableAfterPersistentVolumeClaimChange: %w", err)
|
||||
}
|
||||
if pl.IsPVCRequestedFromPod(logger, modifiedPVC, pod) {
|
||||
logger.V(5).Info("PVC was created or updated and it might make this pod schedulable. PVC is binding to the pod.", "pod", klog.KObj(pod), "PVC", klog.KObj(modifiedPVC))
|
||||
if pl.isPVCRequestedFromPod(logger, modifiedPVC, pod) {
|
||||
logger.V(5).Info("PVC that is referred from the pod was created or updated, which might make this pod schedulable", "pod", klog.KObj(pod), "PVC", klog.KObj(modifiedPVC))
|
||||
return framework.Queue, nil
|
||||
}
|
||||
|
||||
@ -326,19 +326,19 @@ func (pl *VolumeZone) isSchedulableAfterPersistentVolumeClaimChange(logger klog.
|
||||
return framework.QueueSkip, nil
|
||||
}
|
||||
|
||||
// IsPVCRequestedFromPod verifies if the PVC is requested from a given Pod.
|
||||
func (pl *VolumeZone) IsPVCRequestedFromPod(logger klog.Logger, pvc *v1.PersistentVolumeClaim, pod *v1.Pod) bool {
|
||||
// isPVCRequestedFromPod verifies if the PVC is requested from a given Pod.
|
||||
func (pl *VolumeZone) isPVCRequestedFromPod(logger klog.Logger, pvc *v1.PersistentVolumeClaim, pod *v1.Pod) bool {
|
||||
if (pvc == nil) || (pod.Namespace != pvc.Namespace) {
|
||||
return false
|
||||
}
|
||||
pvcNames := pl.getPersistentVolumeClaimNameFromPod(pod)
|
||||
for _, pvcName := range pvcNames {
|
||||
if pvc.Name == pvcName {
|
||||
logger.V(5).Info("PVC matches the pod's PVC", "pod", klog.KObj(pod), "PVC", klog.KObj(pvc))
|
||||
logger.V(5).Info("PVC is referred from the pod", "pod", klog.KObj(pod), "PVC", klog.KObj(pvc))
|
||||
return true
|
||||
}
|
||||
}
|
||||
logger.V(5).Info("PVC doesn't match the pod's PVC", "pod", klog.KObj(pod), "PVC", klog.KObj(pvc))
|
||||
logger.V(5).Info("PVC is not referred from the pod", "pod", klog.KObj(pod), "PVC", klog.KObj(pvc))
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -571,13 +571,13 @@ func TestIsSchedulableAfterPersistentVolumeClaimAdded(t *testing.T) {
|
||||
expectedHint framework.QueueingHint
|
||||
expectedErr bool
|
||||
}{
|
||||
"backoff-wrong-new-object": {
|
||||
"error-wrong-new-object": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
newObj: "not-a-pvc",
|
||||
expectedHint: framework.Queue,
|
||||
expectedErr: true,
|
||||
},
|
||||
"pvc-was-added-but-pod-was-not-bound-to-pvc": {
|
||||
"pvc-was-added-but-pod-refers-no-pvc": {
|
||||
pod: st.MakePod().Name("pod_1").Namespace("default").Obj(),
|
||||
newObj: &v1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||
@ -601,7 +601,7 @@ func TestIsSchedulableAfterPersistentVolumeClaimAdded(t *testing.T) {
|
||||
},
|
||||
expectedHint: framework.QueueSkip,
|
||||
},
|
||||
"pvc-was-added-and-pod-was-bound-to-added-pvc": {
|
||||
"pvc-was-added-and-pod-was-bound-to-the-pvc": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
newObj: &v1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||
@ -609,7 +609,7 @@ func TestIsSchedulableAfterPersistentVolumeClaimAdded(t *testing.T) {
|
||||
},
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
"pvc-was-updated-and-pod-was-bound-to-pvc": {
|
||||
"pvc-was-updated-and-pod-was-bound-to-the-pvc": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
oldObj: &v1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||
@ -621,8 +621,8 @@ func TestIsSchedulableAfterPersistentVolumeClaimAdded(t *testing.T) {
|
||||
},
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
"pvc-was-updated-but-pod-was-not-bound-to-pvc": {
|
||||
pod: createPodWithVolume("pod_1", ""),
|
||||
"pvc-was-updated-but-pod-refers-no-pvc": {
|
||||
pod: st.MakePod().Name("pod_1").Namespace(metav1.NamespaceDefault).Obj(),
|
||||
oldObj: &v1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: ""},
|
||||
|
Loading…
Reference in New Issue
Block a user