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
This commit is contained in:
@@ -768,18 +768,24 @@ class SetVolume(command.Command):
|
|||||||
_("New size must be greater than %s GB") % volume.size
|
_("New size must be greater than %s GB") % volume.size
|
||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
if (
|
if volume.status not in ('available', 'in-use'):
|
||||||
volume.status != 'available'
|
|
||||||
and not volume_client.api_version.matches('3.42')
|
|
||||||
):
|
|
||||||
msg = (
|
msg = (
|
||||||
_(
|
_(
|
||||||
"Volume is in %s state, it must be available "
|
"Volume is in %s state, it must be available "
|
||||||
"before size can be extended"
|
"or in-use before size can be extended."
|
||||||
)
|
)
|
||||||
% volume.status
|
% volume.status
|
||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
if (
|
||||||
|
volume.status == 'in-use'
|
||||||
|
and not volume_client.api_version.matches('3.42')
|
||||||
|
):
|
||||||
|
msg = _(
|
||||||
|
"--os-volume-api-version 3.42 or greater is "
|
||||||
|
"required to extend in-use volumes."
|
||||||
|
)
|
||||||
|
raise exceptions.CommandError(msg)
|
||||||
volume_client.volumes.extend(volume.id, parsed_args.size)
|
volume_client.volumes.extend(volume.id, parsed_args.size)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(_("Failed to set volume size: %s"), e)
|
LOG.error(_("Failed to set volume size: %s"), e)
|
||||||
|
Reference in New Issue
Block a user