From fadc670c95e232a6818bf83dd7d342e9392d706f Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 6 May 2020 11:11:48 +0200 Subject: [PATCH] Send a nicer event when resizing attached Cinder volume Cinder volumes cannot be resized when they're attached. Send a nicer event when it happens: error expanding volume "default/pvc1" of plugin "kubernetes.io/cinder": PVC used by a Pod can not be expanded, please ensure the PVC is not used by any Pod and is fully detached from a node --- .../legacy-cloud-providers/openstack/openstack_volumes.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/openstack_volumes.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/openstack_volumes.go index 4e36987c9df..c965a4ffe08 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/openstack_volumes.go +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/openstack_volumes.go @@ -419,7 +419,12 @@ func (os *OpenStack) ExpandVolume(volumeID string, oldSize resource.Quantity, ne } if volume.Status != volumeAvailableStatus { // cinder volume can not be expanded if its status is not available - return oldSize, fmt.Errorf("volume in %s status can not be expanded, it must be available and not attached to a node", volume.Status) + if volume.Status == volumeInUseStatus { + // Send a nice event when the volume is used + return oldSize, fmt.Errorf("PVC used by a Pod can not be expanded, please ensure the PVC is not used by any Pod and is fully detached from a node") + } + // Send not so nice event when the volume is in any other state (deleted, error) + return oldSize, fmt.Errorf("volume in state %q can not be expanded, it must be \"available\"", volume.Status) } // Cinder works with gigabytes, convert to GiB with rounding up