From b3cb1bdc4a481dffb2e8f47ed7607aa0ac76deb5 Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Fri, 14 Sep 2018 19:22:55 +0800 Subject: [PATCH] Ignore non-available volumes in findMatchingVolume to reduce chance of unnecessary binding failures. --- pkg/controller/volume/persistentvolume/index.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/controller/volume/persistentvolume/index.go b/pkg/controller/volume/persistentvolume/index.go index a23cd6faa0b..4c84abe82e0 100644 --- a/pkg/controller/volume/persistentvolume/index.go +++ b/pkg/controller/volume/persistentvolume/index.go @@ -211,11 +211,18 @@ func findMatchingVolume( } // filter out: + // - volumes in non-available phase // - volumes bound to another claim // - volumes whose labels don't match the claim's selector, if specified // - volumes in Class that is not requested // - volumes whose NodeAffinity does not match the node - if volume.Spec.ClaimRef != nil { + if volume.Status.Phase != v1.VolumeAvailable { + // We ignore volumes in non-available phase, because volumes that + // satisfies matching criteria will be updated to available, binding + // them now has high chance of encountering unnecessary failures + // due to API conflicts. + continue + } else if volume.Spec.ClaimRef != nil { continue } else if selector != nil && !selector.Matches(labels.Set(volume.Labels)) { continue