From edb9a8584c79376dd0ae17f46d79a6cc77c26fe7 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 19 Feb 2021 11:20:20 +0100 Subject: [PATCH] kubelet: better error when generic ephemeral volume is disabled Silently ignoring the unsupported volume type leads to: Warning FailedMount 8s kubelet Unable to attach or mount volumes: unmounted volumes=[my-csi-volume default-token-bsnbz], unattached volumes=[my-csi-volume default-token-bsnbz]: failed to get Plugin from volumeSpec for volume "my-csi-volume" err=no volume plugin matched The new message is easier to understand: Warning FailedMount 6s (x5 over 49s) kubelet Unable to attach or mount volumes: unmounted volumes=[my-csi-volume], unattached volumes=[my-csi-volume default-token-rwlpp]: volume my-csi-volume is a generic ephemeral volume, but that feature is disabled in kubelet --- .../populator/desired_state_of_world_populator.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go index 6cd4d58761b..b222f9224bf 100644 --- a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go +++ b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go @@ -512,8 +512,18 @@ func (dswp *desiredStateOfWorldPopulator) createVolumeSpec( pvcSource := podVolume.VolumeSource.PersistentVolumeClaim ephemeral := false if pvcSource == nil && - podVolume.VolumeSource.Ephemeral != nil && - utilfeature.DefaultFeatureGate.Enabled(features.GenericEphemeralVolume) { + podVolume.VolumeSource.Ephemeral != nil { + if !utilfeature.DefaultFeatureGate.Enabled(features.GenericEphemeralVolume) { + // Provide an unambiguous error message that + // explains why the volume cannot be + // processed. If we just ignore the volume + // source, the error is just a vague "unknown + // volume source". + return nil, nil, "", fmt.Errorf( + "volume %s is a generic ephemeral volume, but that feature is disabled in kubelet", + podVolume.Name, + ) + } // Generic ephemeral inline volumes are handled the // same way as a PVC reference. The only additional // constraint (checked below) is that the PVC must be