Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detaching disk issue: "error detaching VM Disk: Could not detach sdc from" #4164

Closed
7 tasks
pumpkineggs opened this issue Feb 7, 2020 · 1 comment
Closed
7 tasks

Comments

@pumpkineggs
Copy link

pumpkineggs commented Feb 7, 2020

Description
While detaching disk from VM in some cases an error could be thrown like: "error detaching VM Disk: Could not detach sdc from ".

To Reproduce

  1. Create user with name sdaniel
  2. Create a VM owned by the user and attach scsi disk (sda).
  3. Try to detach the disk on running VM.
  4. Get an error.

Expected behavior
Disk detached, no error thrown.

Details

  • Affected Component: vmm_mad
  • Hypervisor: KVM
  • Version: 5.10.x

Additional context
We noticed that "detach_disk" script (vmm_mad/remotes/kvm/detach_disk) should use a more efficient way to check whether a disk detached or not.
While detaching disk from VM in some cases an error could be thrown like: "error detaching VM Disk: Could not detach sdc from ".
But in fact, the disk has been detached from the VM and it can be confirmed via "virsh dumpxml" command.
There is a piece of code in the script:

virsh --connect $LIBVIRT_URI dumpxml $DOMAIN | grep $TARGET > /dev/null 2>&1

if [ $? -eq 0 ] ; then
    error_message "Could not detach $TARGET from $DOMAIN"
    exit -1
fi

Here we have grep $TARGET part where $TARGET turns into a device name (i.e. vda, sda, sdc, etc...).
Let's say we are trying to detach a scsi disk "sda", so the script will run a check with grep sda.
And an interesting part is if the owner of the VM is a user with a name: sdaniel, which is reflected in the domain xml metadata section, grep will return some data and if [ $? -eq 0 ] ; piece will return an error and script will exit with rc=-1 in spite the disk has been detached from the domain.

Proposed changes for the script:
virsh --connect $LIBVIRT_URI dumpxml $DOMAIN | grep dev=\'$TARGET\' > /dev/null 2>&1
Just be more specific about what to grep and extend the regexp to dev=\'$TARGET\'.

Progress Status

  • Branch created
  • Code committed to development branch
  • Testing - QA
  • Documentation
  • Release notes - resolved issues, compatibility, known issues
  • Code committed to upstream release/hotfix branches
  • Documentation committed to upstream release/hotfix branches
atodorov-storpool added a commit to atodorov-storpool/one that referenced this issue Feb 7, 2020
Signed-off-by: Anton Todorov <a.todorov@storpool.com>
atodorov-storpool added a commit to atodorov-storpool/one that referenced this issue Feb 19, 2020
Signed-off-by: Anton Todorov <a.todorov@storpool.com>
rsmontero pushed a commit that referenced this issue Feb 19, 2020
Signed-off-by: Anton Todorov <a.todorov@storpool.com>
rsmontero pushed a commit that referenced this issue Feb 19, 2020
Signed-off-by: Anton Todorov <a.todorov@storpool.com>
(cherry picked from commit 4b17b1f)
@rsmontero
Copy link
Member

merged

rsmontero added a commit to OpenNebula/docs that referenced this issue Feb 19, 2020
atodorov-storpool added a commit to storpool/one that referenced this issue Feb 20, 2020
…#4168)

Signed-off-by: Anton Todorov <a.todorov@storpool.com>
(cherry picked from commit 4b17b1f)
xorel added a commit to xorel/one that referenced this issue Feb 20, 2020
xorel added a commit to xorel/one that referenced this issue Feb 20, 2020
xorel added a commit to xorel/one that referenced this issue Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants