-
Notifications
You must be signed in to change notification settings - Fork 95
Updates in-use volume removal error message #1273
Updates in-use volume removal error message #1273
Conversation
…ing in-use volumes
esx_service/vmdk_ops.py
Outdated
vol_name = vmdk_utils.get_volname_from_vmdk_path(vmdk_path) | ||
logging.info("*** removeVMDK: %s is in use, volume = %s VM = %s VM-uuid = %s (%s)", | ||
vmdk_path, vol_name, attached_vm_name, kv_uuid, ret) | ||
return err("Failed to remove volume {0}, in use by VM = {1} VM-uuid = {2}.".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to remove VM-uuid from the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please update the test result in the PR description.
Got that done too. |
esx_service/vmdk_ops.py
Outdated
@@ -1117,7 +1119,7 @@ def setStatusDetached(vmdk_path): | |||
|
|||
|
|||
def getStatusAttached(vmdk_path): | |||
'''Returns (attached, uuid, attach_as) tuple. For 'detached' status uuid is None''' | |||
'''Returns (attached, uuid, attach_as, vm_name) tuple. For 'detached' status uuid is None''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name is also None in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
@@ -288,7 +288,7 @@ def cloneVMDK(vm_name, vmdk_path, opts={}, vm_uuid=None, datastore_url=None): | |||
lockname = "{}.{}.{}".format(src_datastore, tenant_name, src_volume) | |||
with lockManager.get_lock(lockname): | |||
# Verify if the source volume is in use. | |||
attached, uuid, attach_as = getStatusAttached(src_vmdk_path) | |||
attached, uuid, attach_as, _ = getStatusAttached(src_vmdk_path) | |||
if attached: | |||
if handle_stale_attach(vmdk_path, uuid): | |||
return err("Source volume cannot be in use when cloning") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing this error message to:
"Source volume {0} in use by VM {1} and can't be cloned.".format(vol_name, attached_vm_name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #1275.
logging.info("*** removeVMDK: %s is in use, VM uuid = %s (%s)", vmdk_path, kv_uuid, ret) | ||
return err("Failed to remove volume {0}, in use by VM uuid = {1}.".format( | ||
vmdk_path, kv_uuid)) | ||
if vol_name is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vol_name can't be NULL. This if block can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add this because the function signature is removeVMDK(.., vol_name=None, ..)
and there are a few places from where it's called without the vol_name
parameter. Making the suggested change will need a modification at vmdk_ops.py#L355 and at multiple locations in vmdk_ops_test.py. I can address that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha. I see. You are right.
vol_name = vmdk_utils.get_volname_from_vmdk_path(vmdk_path) | ||
logging.info("*** removeVMDK: %s is in use, volume = %s VM = %s VM-uuid = %s (%s)", | ||
vmdk_path, vol_name, attached_vm_name, kv_uuid, ret) | ||
return err("Failed to remove volume {0}, in use by VM = {1}.".format(vol_name, attached_vm_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume .format can handle NULL attached_vm_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would print .. in use by VM = None
. Is that alright?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error looks weird but that would be stale KV. Fine with me.
logging.info("*** removeVMDK: %s is in use, VM uuid = %s (%s)", vmdk_path, kv_uuid, ret) | ||
return err("Failed to remove volume {0}, in use by VM uuid = {1}.".format( | ||
vmdk_path, kv_uuid)) | ||
if vol_name is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha. I see. You are right.
vol_name = vmdk_utils.get_volname_from_vmdk_path(vmdk_path) | ||
logging.info("*** removeVMDK: %s is in use, volume = %s VM = %s VM-uuid = %s (%s)", | ||
vmdk_path, vol_name, attached_vm_name, kv_uuid, ret) | ||
return err("Failed to remove volume {0}, in use by VM = {1}.".format(vol_name, attached_vm_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error looks weird but that would be stale KV. Fine with me.
@pdhamdhere thanks for the merge! |
Description
This PR updates the error message that's printed on removal of in-use volumes. Changes to the error message are as follows. Fixes #1208.
Signature of the
getStatusAttached(..)
function was modified to return a 4th value i.e.vm_name
, which is needed for building the error message inremoveVMDK(..)
.Test
docker volume rm v2
now displays:ESX Plugin log at
/var/log/vmware/vmdk_ops.log
displays:Please review and merge.
Thanks,
Venil