From 89cb4d0ee9a7f22c70cf1721500a57f8771bcdce Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 26 Aug 2021 13:44:42 +0200 Subject: [PATCH] scheduler: better reason for delay with generic ephemeral volumes These events are currently emitted for a pod using a generic ephemeral volume: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 3s default-scheduler 0/1 nodes are available: 1 persistentvolumeclaim "my-csi-app-inline-volume-my-csi-volume" not found. Warning FailedScheduling 2s default-scheduler 0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims. The one about "persistentvolumeclaim not found" is potentially confusing. It occurs because the scheduler typically checks the pod before the ephemeral volume controller had a chance to create the PVC. This is a bit easier to understand: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 4s default-scheduler 0/1 nodes are available: 1 waiting for ephemeral volume controller to create the persistentvolumeclaim "my-csi-app-inline-volume-my-csi-volume". Warning FailedScheduling 2s default-scheduler 0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims. --- .../framework/plugins/volumebinding/volume_binding.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go b/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go index 384829a2423..c38cdd9fe72 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go +++ b/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go @@ -24,6 +24,7 @@ import ( "time" v1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" utilfeature "k8s.io/apiserver/pkg/util/feature" @@ -140,7 +141,12 @@ func (pl *VolumeBinding) podHasPVCs(pod *v1.Pod) (bool, error) { hasPVC = true pvc, err := pl.PVCLister.PersistentVolumeClaims(pod.Namespace).Get(pvcName) if err != nil { - // The error has already enough context ("persistentvolumeclaim "myclaim" not found") + // The error usually has already enough context ("persistentvolumeclaim "myclaim" not found"), + // but we can do better for generic ephemeral inline volumes where that situation + // is normal directly after creating a pod. + if ephemeral && apierrors.IsNotFound(err) { + err = fmt.Errorf("waiting for ephemeral volume controller to create the persistentvolumeclaim %q", pvcName) + } return hasPVC, err }