From d2cc70ee2caf628e942ed5d4c49b810401c08acc Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 19 Feb 2021 15:46:07 +0100 Subject: [PATCH] scheduler: fail when a pod uses disabled generic ephemeral volumes Without this error, kube-scheduler was simply ignoring the special volume source and scheduled the pod. This was unlikely to work in practice because the volume might have needed binding or the feature is also disabled on kubelet which then doesn't know what to do with the volume. --- pkg/controller/volume/scheduling/scheduler_binder.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/controller/volume/scheduling/scheduler_binder.go b/pkg/controller/volume/scheduling/scheduler_binder.go index 0cd05ddce0d..ae277ef5b31 100644 --- a/pkg/controller/volume/scheduling/scheduler_binder.go +++ b/pkg/controller/volume/scheduling/scheduler_binder.go @@ -674,8 +674,13 @@ func (b *volumeBinder) isVolumeBound(pod *v1.Pod, vol *v1.Volume) (bound bool, p switch { case vol.PersistentVolumeClaim != nil: pvcName = vol.PersistentVolumeClaim.ClaimName - case vol.Ephemeral != nil && - utilfeature.DefaultFeatureGate.Enabled(features.GenericEphemeralVolume): + case vol.Ephemeral != nil: + if !utilfeature.DefaultFeatureGate.Enabled(features.GenericEphemeralVolume) { + return false, nil, fmt.Errorf( + "volume %s is a generic ephemeral volume, but that feature is disabled in kube-scheduler", + vol.Name, + ) + } // Generic ephemeral inline volumes also use a PVC, // just with a computed name, and... pvcName = pod.Name + "-" + vol.Name