-
Notifications
You must be signed in to change notification settings - Fork 95
Unable to unmount/detach volume after vmgroup membership change #1189
Comments
@shuklanirdesh82, can you upload the ESX and plugin logs. Plus the command output for admin CLI vmgroup ls for each vmgroup and list the volumes in each. Pls. update whats the default DS for the _DEFAULT vmgroup, it should be the VM DS i guess. |
If a VM is in a vmgroup with and has volumes attached, then those volumes will be on datastores assigned to the vmgroup. If a VM in a vmgroup has volumes attached to it then don't allow the VM to be migrated out of the vmgroup. The VM can end up in a vmgroup with a different default datastore and which won't resolve the VMDK path in vmdk_ops.py:executeRequest(). And hence detach disk won't happen. Per documentation a VM can access only the volumes on datastores assigned to the VM group. Moving a VM with volumes attached across groups is hence incorrect. When creating a VM group check if the VMs in the list have any volumes mounted (it can be in the default tenant with a default DS (VM_DS)) and disallow placing the VM. |
@govint Looking at code, detach should have succeeded. @shuklanirdesh82 Logs please. |
Once the VM is attached to the new vmgroup, the next command will use the default datastore of the new vmgroup and will try to resolve the VMDK path with that. That won't work because the VMDK is present on the datastore of the earlier vm groujp that the VM belonged to. |
vmdk_ops.py:executeRequest() line 906 the path is the dockvols path on the datastore determined as - default datastore for the vmgroup or the datastore mentioned in the volume name. Then we try to get the vmdk path relative to that DS's dockvols path (line 911). The VM in this case however had a volume attached from its earlier vm group where the vmgroup default DS was VM_DS. The detach req is passing the VMDK name but that won't be resolved on the new dockvols path. Aside from this, the doc clearly says that a VM mustn't be in a vmgroup and using volumes on a DS not assigned to the vmgroup. In this case there is a mismatch between what was allowed (Vm was allowed to be moved to a new vmgroup with a volume atached) and what the doc is saying. |
Any reason why we won't do
Disk is already attached and when container stops, I don't see a reason detach should fail. I can foresee issues where 2 volumes with same name are created in 2 different datastore before and after vmgroup membership change and detach will have to figure out which volume should be detached. |
Yes, that's the reason we can't detach a VMDK from a VM based on VM config. But when VMs from default tenant are moved to a named tenant, we need to do this check in tenant |
Here are the logs. vm1_docker-volume-vsphere.txt |
Docker won't allow two volumes to be created with the same name and if user provides the @datastore format then those are separate volumes as far as Docker is concerned. And when the ESX service gets the volume name as name@datastore we use that datastore to figure the VMDK path. Otherwise its always the default datastore of the vm group thats used to create the volume path. As mentioned in earlier update once the VM is assigned to a new vmgroup its docker volume disks are assumed to be on the default DS of that vmgroup. @shuklanirdesh82, the vmdk_ops logs are not uploaded, can you attach those. |
@govint I have attached the logs (vmdk_ops.txt) |
From the plugin and service logs, the user has used vol-name@DS format, which means the service will try to use the DS mentioned in the vol-name.
Plugin: Service: Overall, this issue won't happen if new vmgroup has access rights set for the old DS. But if thats not the case, the service code is handling the condition correctly and flagging the error. The proposed fix still applies as the correct way where to disallow the membership of VMs to a vmgroup create if volumes attached to the VMs. |
@govint I agree with your proposed fix and here is what I can think of that not allows us to directly look at vmdk config and detach vmdk.
|
I'll check, I thought this was the only place where the check was missing. |
Updated diff and pushed. |
Fixed via #1190. |
volume stays as attached even after detaching from container
Test bed setup:
Steps to reproduce:
docker volume create -d vsphere vol1
vmdkops_admin.py volume ls
docker volume ls
anddocker volume inspect
to verify vol1 propertiesdocker run --rm -it -v vol1@sharedVmfs-0:/vol1 --name cnt_abc11 busybox
attached
state anddocker volume inspect
shows the sameADMIN CLI volume ls
to make sure the volume is still in attached statedocker volume inspect vol1
docker volume inspect
or Admin CLI still says volume is attached to VM1docker volume inspect vol1
<<< volume is still in attached state12: E1:
vmdkops_admin.py volume ls
still shows it is attached stateExpectation: step#11 and step#12 should not show
vol1
as attached after detaching containerNote: vmgroup created at step#6 becomes not removable, vm1 is part of named tenant and fail to remove as shown below
The text was updated successfully, but these errors were encountered: