Skip to content

Commit 03933e9

Browse files
committed
Fix: extend in-use volumes check
Currently we have 2 issues with extending volumes checks: 1. We don't specify explicitly that MV 3.42 needs to be passed for in-use volumes 2. Any state of volume (error, attaching, detaching etc) can pass this check by specifying MV 3.42 The fundamentally correct approach to these checks should be: 1. Only allow 'available' and 'in-use' volumes to be extended 2. Check MV 3.42 or greater is specified in case of 'in-use' volumes otherwise fail This approach is implemented in the patch. Change-Id: I45ab9af953f7d060379f48ca429eaea7cfe857cc
1 parent ecc744a commit 03933e9

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

openstackclient/volume/v3/volume.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -768,18 +768,24 @@ def take_action(self, parsed_args):
768768
_("New size must be greater than %s GB") % volume.size
769769
)
770770
raise exceptions.CommandError(msg)
771-
if (
772-
volume.status != 'available'
773-
and not volume_client.api_version.matches('3.42')
774-
):
771+
if volume.status not in ('available', 'in-use'):
775772
msg = (
776773
_(
777774
"Volume is in %s state, it must be available "
778-
"before size can be extended"
775+
"or in-use before size can be extended."
779776
)
780777
% volume.status
781778
)
782779
raise exceptions.CommandError(msg)
780+
if (
781+
volume.status == 'in-use'
782+
and not volume_client.api_version.matches('3.42')
783+
):
784+
msg = _(
785+
"--os-volume-api-version 3.42 or greater is "
786+
"required to extend in-use volumes."
787+
)
788+
raise exceptions.CommandError(msg)
783789
volume_client.volumes.extend(volume.id, parsed_args.size)
784790
except Exception as e:
785791
LOG.error(_("Failed to set volume size: %s"), e)

0 commit comments

Comments
 (0)