-
Notifications
You must be signed in to change notification settings - Fork 95
Handling dockvols symlink on vsanDatastore to update volume status on VM poweroff event #1235
Conversation
… VM poweroff event
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.
The code is clean but it seems to be redundant with check_docker_volume(). Which also seems to have the same issue.
I suggest changing 'bool check_docker_volume' to ' 'disk_path docker_volume_path(dev)' (return None if not a path, returns path if it is) , fix the issue with realpath and use this in both new code and check_volumes_mounted
Oops, ignore. I was looking at a stale branch. LGTM with a couple of nits
@@ -64,6 +64,9 @@ | |||
VMDK_RETRY_COUNT = 5 | |||
VMDK_RETRY_SLEEP = 1 | |||
|
|||
# root for all the volumes | |||
VOLUME_ROOT = "/vmfs/volumes/" |
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.
If you introduce this (which is good), you'd have to update the code to use it, at east in vmdk_utils.py
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.
Sure
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.
this string has been used as a part regex in some. Will do this as a part refactoring all constants in our vmdkops and vmdk_utils separately.
if disk_path.startswith(vmdk_ops.DOCK_VOLS_DIR): | ||
# returning the vmdk path for dvs volume | ||
return os.path.join("/vmfs/volumes/", datastore, disk_path) | ||
# find the dockvols dir on current datastore and resolve symlinks if any |
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.
Please add comment to L339 that 'dev' is of type vim.Device (I think)
esx_service/utils/vmdk_utils.py
Outdated
return os.path.join("/vmfs/volumes/", datastore, disk_path) | ||
# find the dockvols dir on current datastore and resolve symlinks if any | ||
dvol_dir_path = os.path.realpath(os.path.join(VOLUME_ROOT, | ||
datastore, vmdk_ops.DOCK_VOLS_DIR)) |
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.
nit: better to name it datastore_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.
LGTM.
@@ -64,6 +64,9 @@ | |||
VMDK_RETRY_COUNT = 5 | |||
VMDK_RETRY_SLEEP = 1 | |||
|
|||
# root for all the volumes | |||
VOLUME_ROOT = "/vmfs/volumes/" |
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.
Not related to your change: the string "/vmfs/volumes" has been hardcoded everywhere in our code base. We should refactor those code to use this constant. Let's file an issue for tracking purpose.
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 use this constant in this file for now.
#1236 for usages of constants in our esx side code. |
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.
Resolving the symlinks for dockvols directory for a datastore and using it to decide if it is a vDVS volume.
Fixes #1233
Testing: