-
Notifications
You must be signed in to change notification settings - Fork 95
Persisting VM name in KV while attaching volume #1064
Conversation
1. Persisting vm name along with uuid in KV when a volume is attached to a VM 2. If vm name cannot be retrieved using uuid (VM might reside on another host) then use the vm name persisted in KV. Using this in both for admincli and plugin requests Fixes #1053
esx_service/cli/vmdkops_admin.py
Outdated
if metadata[kv.ATTACHED_VM_UUID]: | ||
return metadata[kv.ATTACHED_VM_UUID] | ||
return metadata[kv.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.
For existing volumes which do not have VM_NAME in KV, it will return NULL. Did you check if code handles it correctly?
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 see. For such cases, fixing it to return vm uuid (like before). Thanks
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.
In ideal behavior, there will be name persisted in KV (while attach) even for volume that were created previously (with version of DVS without this change).
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.
yes, but people can upgrade VIB while the volumes are attached ...
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.
Got it!.thanks.
We will print uuid then!
Change looks good except that case Prashant pointed out. Moreover, KV Store is just one of our persistence stores. We still need to fix the same in the auth_db. Do we plan to address that in a separate issue&PR (maybe as part of the cross-esx multi tenancy support)? |
@shaominchen |
@pshahzeb |
…persisting VM name in metadata
OK cool. Thanks |
Fix is good but can we just print the UUID (like for the admin ls) when the UUID doesn't resolve to the a VM object on the local host. |
esx_service/cli/vmdkops_admin.py
Outdated
if vm_name: | ||
return vm_name | ||
# If vm name couldn't be retrieved through uuid, use name from KV | ||
elif metadata[kv.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.
Better to check kv.ATTACHED_VM_NAME is in metadata
esx_service/vmdk_ops.py
Outdated
if vm: | ||
vinfo[ATTACHED_TO_VM] = vm.config.name | ||
vm = findVmByUuid(vol_meta[kv.ATTACHED_VM_UUID]) | ||
if vm: |
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.
Can we use vmdk_ops.vm_uuid2name{} here as well.
esx_service/vmdk_ops.py
Outdated
vm = findVmByUuid(vol_meta[kv.ATTACHED_VM_UUID]) | ||
if vm: | ||
vinfo[ATTACHED_TO_VM] = vm.config.name | ||
elif vol_meta[kv.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.
Again check if kv.ATTACHED_VM_NAME is in vol_meta before indexing vol_meta with it,
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.
Couple of changes.
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.
Overall looks good and looks like all proper comments have already been made. So I second a few of them
(1) need to make sure if behaves fine with current KV (they one that does not have attached-vm info
(2) I agree with @govint that a fallback (if no name anywhere) should bu just to print UUID
(3) I think any work related to DB is out of scope... Please note that DB is really access/quota config DB, not a generic tracking mechanism
…on host and is not persisted in KV store
Addressed all the comments and also fallback to uuid if no name anywhere. But this shouldn't happen unless admin did an upgrade between mount and unmount unmount which looks impossible. |
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.
to a VM
then use the vm name persisted in KV. Doing this in both for admincli and plugin
requests
After Fix:
Setup : 2 ESXs ESX1 & ESX2 with VM1 and VM2 respectively and shared DS
Created 2 volumes, vol1 from VM1 and vol2 from VM2
admin ls from ESX1
admin ls from ESX2
Ran the container from VM1 and mounted the volume - vol2
docker volume inspect vol2 from VM1
docker volume inspect vol2 from VM2
admin ls from ESX1
admin ls from ESX2
Fixes #1053