-
Notifications
You must be signed in to change notification settings - Fork 95
Confusing error message from volume.create when datastore is not writ… #718
Changes from 5 commits
646bd04
56fe3be
832fbdf
02d74b2
a528ed6
11631ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,24 +490,27 @@ def get_vol_path(datastore, tenant_name=None): | |
if os.path.isdir(path): | ||
# If the path exists then return it as is. | ||
logging.debug("Found %s, returning", path) | ||
return path | ||
return path, None | ||
|
||
if not os.path.isdir(dock_vol_path): | ||
# The osfs tools are usable for DOCK_VOLS_DIR on all datastores | ||
cmd = "{0} {1}".format(OSFS_MKDIR_CMD, dock_vol_path) | ||
rc, out = RunCommand(cmd) | ||
if rc != 0: | ||
logging.warning("Failed to create %s", dock_vol_path) | ||
return None | ||
errMsg = "{0} creation failed - {1} on {2}".format(DOCK_VOLS_DIR, os.strerror(rc), datastore) | ||
logging.warning(errMsg) | ||
return None, err(errMsg) | ||
if tenant_name and not os.path.isdir(path): | ||
# The mkdir command is used to create "tenant_name" folder inside DOCK_VOLS_DIR on "datastore" | ||
cmd = "{0} {1}".format(MKDIR_CMD, path) | ||
rc, out = RunCommand(cmd) | ||
if rc != 0: | ||
logging.warning("Failed to create %s", path) | ||
return None | ||
errMsg = "Failed to initialize volume path {0}".format(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not include error string here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is mkdir is that it returns either 0 or 1. 0 on success and 1 on failure for any reason. Inorder to simulate this condition, where it fails on creating a tenant and is successful on dockvol creation. I have changed the access permissions on dockvol. For example, when I printed the rc, out values to log Here, it clearly shows the error statement but return code is 1 which stands for "Operation not permitted".
For that reason, I just settled with a normal message without the reason. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not then log "out" which already has error string? |
||
logging.warning(errMsg) | ||
return None, err(errMsg) | ||
|
||
logging.info("Created %s", path) | ||
return path | ||
return path, None | ||
|
||
def parse_vol_name(full_vol_name): | ||
""" | ||
|
@@ -599,10 +602,10 @@ def executeRequest(vm_uuid, vm_name, config_path, cmd, full_vol_name, opts): | |
return err(error_info) | ||
|
||
# get /vmfs/volumes/<volid>/dockvols path on ESX: | ||
path = get_vol_path(datastore, tenant_name) | ||
path, errMsg = get_vol_path(datastore, tenant_name) | ||
logging.debug("executeRequest %s %s", tenant_name, path) | ||
if path is None: | ||
return err("Failed to initialize volume path {0}".format(path)) | ||
return errMsg | ||
|
||
vmdk_path = vmdk_utils.get_vmdk_path(path, vol_name) | ||
|
||
|
@@ -1097,7 +1100,7 @@ def set_vol_opts(name, options): | |
return False | ||
|
||
# get /vmfs/volumes/<datastore>/dockvols path on ESX: | ||
path = get_vol_path(datastore) | ||
path, errMsg = get_vol_path(datastore) | ||
|
||
if path is None: | ||
msg = "Failed to get datastore path {0}".format(path) | ||
|
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.
Why did you delete this code? This need to exist. See #687
OSFS_MKDIR_CMD is used to create dock_vol_path and MKDIR_CMD is used to create Tenant folder.
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 didn't delete any code. It achieves the same functionality as before. I just remodified the code so that it looks simpler now.