apache / cloudstack

Apache CloudStack is an opensource Infrastructure as a Service (IaaS) cloud computing platform
https://cloudstack.apache.org/
Apache License 2.0
2.05k stars 1.1k forks source link

can't start vm when reattaching root volume #6492

Closed bugoff closed 2 years ago

bugoff commented 2 years ago
ISSUE TYPE
COMPONENT NAME
API
CLOUDSTACK VERSION
4.17.0.0
CONFIGURATION
OS / ENVIRONMENT
SUMMARY

when you migrate a root disk to a new vm which already has a root disk, it is migrated as a datadisk, when you migrate the disk back to the original vm, you are not able to start the instance because there is no root disk found.

STEPS TO REPRODUCE
create a new vm, detach the root volume and attach it to another vm.
Reattach the volume to the original vm and try to start it.
EXPECTED RESULTS
the vm should start or i should be able to to change the volume_type
ACTUAL RESULTS
error:
Unable to prepare volumes for vm as ROOT volume is missing
boring-cyborg[bot] commented 2 years ago

Thanks for opening your first issue here! Be sure to follow the issue template!

shwstppr commented 2 years ago

Thanks @bugoff for reporting the issue. I'm able to reproduce this with 4.17 and main. ~But you can workaround this using API and providing~ You need to provide deviceid=0 while calling attachVolume API for reattaching volume to the original VM. I tested this with a VMware env,

(localcloud) 🐱 > list volumes virtualmachineid=23dc8b23-934e-4b34-aeb9-e5c09d2223e9 filter=id,name,virtualmachineid,type,
{
  "count": 1,
  "volume": [
    {
      "id": "774fd83e-147a-4cc1-a8cc-7aeb50247a3b",
      "name": "ROOT-109",
      "type": "ROOT",
      "virtualmachineid": "23dc8b23-934e-4b34-aeb9-e5c09d2223e9"
    }
  ]
}
(localcloud) 🐱 > detach volume id=774fd83e-147a-4cc1-a8cc-7aeb50247a3b 
{
  "volume": {
    "account": "admin",
    "chaininfo": "{\"diskDeviceBusName\":\"scsi0:0\",\"diskChain\":[\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] i-2-109-VM/ROOT-109.vmdk\",\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] c97b3014d71a3a74b2b35b5028e25ee3/c97b3014d71a3a74b2b35b5028e25ee3.vmdk\"]}",
    "clusterid": "43e1023b-8448-4186-bbf4-5893700c87bd",
    "clustername": "p1-c1",
    "created": "2022-06-22T21:34:28+0000",
    "destroyed": false,
    "displayvolume": true,
    "domain": "ROOT",
    "domainid": "9d73d80c-e6fc-11ec-8b48-1e00230002ea",
    "externaluuid": "6000C29c-9a57-1125-b255-7968af0890fa",
    "hasannotations": false,
    "hypervisor": "VMware",
    "id": "774fd83e-147a-4cc1-a8cc-7aeb50247a3b",
    "isextractable": true,
    "jobid": "6c5a9ec5-7b52-450f-a950-436911293715",
    "jobstatus": 0,
    "name": "ROOT-109",
    "path": "ROOT-109",
    "podid": "46d11678-0137-4063-94da-83ceac0671de",
    "podname": "Pod1",
    "provisioningtype": "thin",
    "quiescevm": false,
    "serviceofferingdisplaytext": "Small Instance",
    "serviceofferingid": "1",
    "serviceofferingname": "Small Instance",
    "size": 2147483648,
    "state": "Ready",
    "storage": "pr6425-t4310-vmware-67u3-esxi-pri1",
    "storageid": "0e5d9ebf-0c9d-30c3-b0f2-a4569aac5de9",
    "storagetype": "shared",
    "supportsstoragesnapshot": false,
    "tags": [],
    "templatedisplaytext": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "templateid": "9d77bc18-e6fc-11ec-8b48-1e00230002ea",
    "templatename": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "type": "DATADISK",
    "zoneid": "1749b71f-3cc7-4889-9d09-c47042f273dd",
    "zonename": "pr6425-t4310-vmware-67u3"
  }
}

Attach and detach volume to/from another VM

(localcloud) 🐱 > attach volume id=774fd83e-147a-4cc1-a8cc-7aeb50247a3b virtualmachineid=18a00bc9-d3ac-440e-b9b2-81a0f7a60ba5 
{
  "volume": {
    "account": "admin",
    "attached": "2022-06-24T07:45:36+0000",
    "chaininfo": "{\"diskDeviceBusName\":\"scsi0:0\",\"diskChain\":[\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] i-2-130-VM/ROOT-109.vmdk\",\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] c97b3014d71a3a74b2b35b5028e25ee3/c97b3014d71a3a74b2b35b5028e25ee3.vmdk\"]}",
    "clusterid": "43e1023b-8448-4186-bbf4-5893700c87bd",
    "clustername": "p1-c1",
    "created": "2022-06-22T21:34:28+0000",
    "destroyed": false,
    "deviceid": 1,
    "diskioread": 0,
    "diskiowrite": 0,
    "diskkbsread": 0,
    "diskkbswrite": 0,
    "displayvolume": true,
    "domain": "ROOT",
    "domainid": "9d73d80c-e6fc-11ec-8b48-1e00230002ea",
    "externaluuid": "6000C29c-9a57-1125-b255-7968af0890fa",
    "hasannotations": false,
    "hypervisor": "VMware",
    "id": "774fd83e-147a-4cc1-a8cc-7aeb50247a3b",
    "isextractable": true,
    "jobid": "1dfe67ed-1632-49bf-bbaf-16cbdc48bfd8",
    "jobstatus": 0,
    "name": "ROOT-109",
    "path": "ROOT-109",
    "podid": "46d11678-0137-4063-94da-83ceac0671de",
    "podname": "Pod1",
    "provisioningtype": "thin",
    "quiescevm": false,
    "serviceofferingdisplaytext": "Small Instance",
    "serviceofferingid": "1",
    "serviceofferingname": "Small Instance",
    "size": 2147483648,
    "state": "Ready",
    "storage": "pr6425-t4310-vmware-67u3-esxi-pri1",
    "storageid": "0e5d9ebf-0c9d-30c3-b0f2-a4569aac5de9",
    "storagetype": "shared",
    "supportsstoragesnapshot": false,
    "tags": [],
    "templatedisplaytext": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "templateid": "9d77bc18-e6fc-11ec-8b48-1e00230002ea",
    "templatename": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "type": "DATADISK",
    "virtualmachineid": "18a00bc9-d3ac-440e-b9b2-81a0f7a60ba5",
    "vmdisplayname": "newvm",
    "vmname": "newvm",
    "vmstate": "Running",
    "zoneid": "1749b71f-3cc7-4889-9d09-c47042f273dd",
    "zonename": "pr6425-t4310-vmware-67u3"
  }
}
(localcloud) 🐱 > detach volume id=774fd83e-147a-4cc1-a8cc-7aeb50247a3b 
{
  "volume": {
    "account": "admin",
    "chaininfo": "{\"diskDeviceBusName\":\"scsi0:0\",\"diskChain\":[\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] i-2-130-VM/ROOT-109.vmdk\",\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] c97b3014d71a3a74b2b35b5028e25ee3/c97b3014d71a3a74b2b35b5028e25ee3.vmdk\"]}",
    "clusterid": "43e1023b-8448-4186-bbf4-5893700c87bd",
    "clustername": "p1-c1",
    "created": "2022-06-22T21:34:28+0000",
    "destroyed": false,
    "displayvolume": true,
    "domain": "ROOT",
    "domainid": "9d73d80c-e6fc-11ec-8b48-1e00230002ea",
    "externaluuid": "6000C29c-9a57-1125-b255-7968af0890fa",
    "hasannotations": false,
    "hypervisor": "VMware",
    "id": "774fd83e-147a-4cc1-a8cc-7aeb50247a3b",
    "isextractable": true,
    "jobid": "30b87c39-a792-4673-bd4d-e549365ae4d3",
    "jobstatus": 0,
    "name": "ROOT-109",
    "path": "ROOT-109",
    "podid": "46d11678-0137-4063-94da-83ceac0671de",
    "podname": "Pod1",
    "provisioningtype": "thin",
    "quiescevm": false,
    "serviceofferingdisplaytext": "Small Instance",
    "serviceofferingid": "1",
    "serviceofferingname": "Small Instance",
    "size": 2147483648,
    "state": "Ready",
    "storage": "pr6425-t4310-vmware-67u3-esxi-pri1",
    "storageid": "0e5d9ebf-0c9d-30c3-b0f2-a4569aac5de9",
    "storagetype": "shared",
    "supportsstoragesnapshot": false,
    "tags": [],
    "templatedisplaytext": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "templateid": "9d77bc18-e6fc-11ec-8b48-1e00230002ea",
    "templatename": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "type": "DATADISK",
    "zoneid": "1749b71f-3cc7-4889-9d09-c47042f273dd",
    "zonename": "pr6425-t4310-vmware-67u3"
  }
}

VM is now a datadisk

(localcloud) 🐱 > list volumes id=774fd83e-147a-4cc1-a8cc-7aeb50247a3b filter=id,name,virtualmachineid,type,
{
  "count": 1,
  "volume": [
    {
      "id": "774fd83e-147a-4cc1-a8cc-7aeb50247a3b",
      "name": "ROOT-109",
      "type": "DATADISK"
    }
  ]
}

Attach volume to the original VM while passing deviceid

(localcloud) 🐱 > attach volume id=774fd83e-147a-4cc1-a8cc-7aeb50247a3b virtualmachineid=23dc8b23-934e-4b34-aeb9-e5c09d2223e9 deviceid=0
{
  "volume": {
    "account": "admin",
    "attached": "2022-06-24T07:46:36+0000",
    "chaininfo": "{\"diskDeviceBusName\":\"scsi0:0\",\"diskChain\":[\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] i-2-109-VM/ROOT-109.vmdk\",\"[0e5d9ebf0c9d30c3b0f2a4569aac5de9] c97b3014d71a3a74b2b35b5028e25ee3/c97b3014d71a3a74b2b35b5028e25ee3.vmdk\"]}",
    "clusterid": "43e1023b-8448-4186-bbf4-5893700c87bd",
    "clustername": "p1-c1",
    "created": "2022-06-22T21:34:28+0000",
    "destroyed": false,
    "deviceid": 0,
    "diskioread": 0,
    "diskiowrite": 0,
    "diskkbsread": 0,
    "diskkbswrite": 3,
    "displayvolume": true,
    "domain": "ROOT",
    "domainid": "9d73d80c-e6fc-11ec-8b48-1e00230002ea",
    "externaluuid": "6000C29c-9a57-1125-b255-7968af0890fa",
    "hasannotations": false,
    "hypervisor": "VMware",
    "id": "774fd83e-147a-4cc1-a8cc-7aeb50247a3b",
    "isextractable": true,
    "jobid": "2191ec75-e90d-4b37-a57f-92bc50668bee",
    "jobstatus": 0,
    "name": "ROOT-109",
    "path": "ROOT-109",
    "podid": "46d11678-0137-4063-94da-83ceac0671de",
    "podname": "Pod1",
    "provisioningtype": "thin",
    "quiescevm": false,
    "serviceofferingdisplaytext": "Small Instance",
    "serviceofferingid": "1",
    "serviceofferingname": "Small Instance",
    "size": 2147483648,
    "state": "Ready",
    "storage": "pr6425-t4310-vmware-67u3-esxi-pri1",
    "storageid": "0e5d9ebf-0c9d-30c3-b0f2-a4569aac5de9",
    "storagetype": "shared",
    "supportsstoragesnapshot": false,
    "tags": [],
    "templatedisplaytext": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "templateid": "9d77bc18-e6fc-11ec-8b48-1e00230002ea",
    "templatename": "CentOS 5.3(64-bit) no GUI (vSphere)",
    "type": "ROOT",
    "virtualmachineid": "23dc8b23-934e-4b34-aeb9-e5c09d2223e9",
    "vmdisplayname": "VM-23dc8b23-934e-4b34-aeb9-e5c09d2223e9",
    "vmname": "VM-23dc8b23-934e-4b34-aeb9-e5c09d2223e9",
    "vmstate": "Stopped",
    "zoneid": "1749b71f-3cc7-4889-9d09-c47042f273dd",
    "zonename": "pr6425-t4310-vmware-67u3"
  }
}
(localcloud) 🐱 > list volumes id=774fd83e-147a-4cc1-a8cc-7aeb50247a3b filter=id,name,virtualmachineid,type,
{
  "count": 1,
  "volume": [
    {
      "id": "774fd83e-147a-4cc1-a8cc-7aeb50247a3b",
      "name": "ROOT-109",
      "type": "ROOT",
      "virtualmachineid": "23dc8b23-934e-4b34-aeb9-e5c09d2223e9"
    }
  ]
}

Start VM

(localcloud) 🐱 > start virtualmachine id=23dc8b23-934e-4b34-aeb9-e5c09d2223e9 filter=id,name,state
{}
(localcloud) 🐱 > list virtualmachines id=23dc8b23-934e-4b34-aeb9-e5c09d2223e9 filter=id,name,state
{
  "count": 1,
  "virtualmachine": [
    {
      "id": "23dc8b23-934e-4b34-aeb9-e5c09d2223e9",
      "name": "VM-23dc8b23-934e-4b34-aeb9-e5c09d2223e9",
      "state": "Running"
    }
  ]
}

~I'll try to add a change in UI to support this~ You can also provide deviceid while using the attach operation in UI Screenshot from 2022-06-24 13-27-47

bugoff commented 2 years ago

Hi, thanks for the update, it wasn't clear to me when i set the deviceid to 0 it would change it to a ROOT disk.

shwstppr commented 2 years ago

@bugoff did it solved the issue for you? Maybe we need to make the documentation more clearer for this behaviour

bugoff commented 2 years ago

hi @shwstppr i tested this and i can confirm this works. Thanks for the help.

I think it would definitely help if the docs are bit clearer about this.

harikrishna-patnala commented 2 years ago

Verified the scenarios and I agree with @shwstppr. To give some information about the device ID 0, added some information in the Device ID section in attach Volume form. https://github.com/apache/cloudstack/pull/6518

rohityadavcloud commented 2 years ago

Is this fixed with https://github.com/apache/cloudstack/pull/6518 @harikrishna-patnala ?

harikrishna-patnala commented 2 years ago

Yes @rohityadavcloud

harikrishna-patnala commented 2 years ago

While reattaching the root volume to the VM, then device id 0 has to be used. We have added that information in the Device ID details section in the PR #6518