Repository navigation
Closed
Description
This issue is almost the same as the #3957
ISSUE TYPE
- Bug Report
COMPONENT NAME
Instance reinstallation
CLOUDSTACK VERSION
main,
4.17,
but not in 4.14
SUMMARY
Reinstall action acts surprisingly. When users reinstall a vm, they expect the VM configurations stay the same (like: service offering, volume sizes, IP) and a brand new operating system installs on the VM. But it is not always true. For example:
First Scenario:
- Deploy an instance.
Don't override the root disk - Resize the root volume
- Reinstall the VM
| Expected Result | Actual Result |
|---|---|
| Root volume size stays the same | Root volume size resets to original value |
First Scenario:
- Deploy an instance.
Override the root disk - Resize the root volume
- Reinstall the VM
| Expected Result | Actual Result |
|---|---|
| Root volume size stays the same | Root volume size stays the same |
Findings
In our debugging we noticed that when user overrides the root disk size an entry in user_vm_details is created. When user don't override root disk size, the entry is not created in database. In that case, CloudStack uses the template's disk size rather than the old root volume size in reinstallation process.
mysql> select * from user_vm_details where name = 'rootdisksize' ;
+----+-------+--------------+-------+---------+
| id | vm_id | name | value | display |
+----+-------+--------------+-------+---------+
| 21 | 5 | rootdisksize | 15 | 1 |
+----+-------+--------------+-------+---------+
1 row in set (0.00 sec)
cloudstack/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Lines 7746 to 7752 in eac357c
| if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.ROOT_DISK_SIZE) == null && !newVol.getSize().equals(template.getSize())) { | |
| VolumeVO resizedVolume = (VolumeVO) newVol; | |
| if (template.getSize() != null) { | |
| resizedVolume.setSize(template.getSize()); | |
| _volsDao.update(resizedVolume.getId(), resizedVolume); | |
| } | |
| } |
Activity
DaanHoogland commentedon Feb 1, 2023
fixed by #7145
soreana commentedon Feb 10, 2023
@weizhouapache
Although the #7145 PR fixed the issue for new VMs, we have to update CloudStack's database manually and add an entry in
user_vm_detailsfor old VMs. I thought it would be nice to share the scrips here just in case someone has the same issue. :-)missing.txtpython3 parser.py missingmissing.sqlfile.missing.sqlweizhouapache commentedon Feb 11, 2023
thanks @soreana for sharing
would it be good do it via mysql procedure?
soreana commentedon Feb 16, 2023
@weizhouapache We had a lot of edge cases, we prefer to get the list first and manually update those. :-)