From d9f532029e8955fb08394c2be3e316b9ed2cfe2e Mon Sep 17 00:00:00 2001 From: Abdullah Gharaibeh Date: Tue, 11 Aug 2020 13:06:57 -0400 Subject: [PATCH] "unbound immediate PersistentVolumeClaims" should be UnschedulableAndUnresolvable error This was fixed in 1.19 by refactoring that part into PreFilter in https://github.com/kubernetes/kubernetes/pull/91775 --- .../volume/scheduling/scheduler_binder.go | 4 ++- .../scheduling/scheduler_binder_test.go | 30 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pkg/controller/volume/scheduling/scheduler_binder.go b/pkg/controller/volume/scheduling/scheduler_binder.go index f53f7567fae..af0ff07f0cb 100644 --- a/pkg/controller/volume/scheduling/scheduler_binder.go +++ b/pkg/controller/volume/scheduling/scheduler_binder.go @@ -61,6 +61,8 @@ const ( ErrReasonBindConflict ConflictReason = "node(s) didn't find available persistent volumes to bind" // ErrReasonNodeConflict is used for VolumeNodeAffinityConflict predicate error. ErrReasonNodeConflict ConflictReason = "node(s) had volume node affinity conflict" + // ErrUnboundImmediatePVC is used when the pod has an unbound PVC in immedate binding mode. + ErrUnboundImmediatePVC ConflictReason = "pod has unbound immediate PersistentVolumeClaims" ) // InTreeToCSITranslator contains methods required to check migratable status @@ -258,7 +260,7 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (reasons Confl // Immediate claims should be bound if len(unboundClaimsImmediate) > 0 { - return nil, fmt.Errorf("pod has unbound immediate PersistentVolumeClaims") + return ConflictReasons{ErrUnboundImmediatePVC}, nil } // Check PV node affinity on bound volumes diff --git a/pkg/controller/volume/scheduling/scheduler_binder_test.go b/pkg/controller/volume/scheduling/scheduler_binder_test.go index 9c4dda0c73f..84531ea146b 100644 --- a/pkg/controller/volume/scheduling/scheduler_binder_test.go +++ b/pkg/controller/volume/scheduling/scheduler_binder_test.go @@ -809,9 +809,9 @@ func TestFindPodVolumesWithoutProvisioning(t *testing.T) { shouldFail: true, }, "prebound-pvc": { - podPVCs: []*v1.PersistentVolumeClaim{preboundPVC}, - pvs: []*v1.PersistentVolume{pvNode1aBound}, - shouldFail: true, + podPVCs: []*v1.PersistentVolumeClaim{preboundPVC}, + pvs: []*v1.PersistentVolume{pvNode1aBound}, + reasons: ConflictReasons{ErrUnboundImmediatePVC}, }, "unbound-pvc,pv-same-node": { podPVCs: []*v1.PersistentVolumeClaim{unboundPVC}, @@ -850,9 +850,9 @@ func TestFindPodVolumesWithoutProvisioning(t *testing.T) { reasons: ConflictReasons{ErrReasonBindConflict}, }, "one-prebound,one-unbound": { - podPVCs: []*v1.PersistentVolumeClaim{unboundPVC, preboundPVC}, - pvs: []*v1.PersistentVolume{pvNode1a, pvNode1b}, - shouldFail: true, + podPVCs: []*v1.PersistentVolumeClaim{unboundPVC, preboundPVC}, + pvs: []*v1.PersistentVolume{pvNode1a, pvNode1b}, + reasons: ConflictReasons{ErrUnboundImmediatePVC}, }, "immediate-bound-pvc": { podPVCs: []*v1.PersistentVolumeClaim{immediateBoundPVC}, @@ -864,17 +864,17 @@ func TestFindPodVolumesWithoutProvisioning(t *testing.T) { reasons: ConflictReasons{ErrReasonNodeConflict}, }, "immediate-unbound-pvc": { - podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC}, - shouldFail: true, + podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC}, + reasons: ConflictReasons{ErrUnboundImmediatePVC}, }, "immediate-unbound-pvc,delayed-mode-bound": { - podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC, boundPVC}, - pvs: []*v1.PersistentVolume{pvBound}, - shouldFail: true, + podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC, boundPVC}, + pvs: []*v1.PersistentVolume{pvBound}, + reasons: ConflictReasons{ErrUnboundImmediatePVC}, }, "immediate-unbound-pvc,delayed-mode-unbound": { - podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC, unboundPVC}, - shouldFail: true, + podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC, unboundPVC}, + reasons: ConflictReasons{ErrUnboundImmediatePVC}, }, } @@ -965,8 +965,8 @@ func TestFindPodVolumesWithProvisioning(t *testing.T) { expectedProvisions: []*v1.PersistentVolumeClaim{selectedNodePVC}, }, "immediate-unbound-pvc": { - podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC}, - shouldFail: true, + podPVCs: []*v1.PersistentVolumeClaim{immediateUnboundPVC}, + reasons: ConflictReasons{ErrUnboundImmediatePVC}, }, "one-immediate-bound,one-provisioned": { podPVCs: []*v1.PersistentVolumeClaim{immediateBoundPVC, provisionedPVC},