Skip to content

Commit d5241d3

Browse files
committed
Merge release branch 4.19 to main
* 4.19: Fix: Update rootdisksize detail on restore VM (#8981) UI: hide Cleanup/Expunge when delete a CloudManaged CKS cluster (#8593)
2 parents db572f4 + 0271494 commit d5241d3

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8115,17 +8115,25 @@ public Pair<UserVmVO, Volume> doInTransaction(final TransactionStatus status) th
81158115
private void updateVolume(Volume vol, VMTemplateVO template, UserVmVO userVm, DiskOffering diskOffering, Map<String, String> details) {
81168116
VolumeVO resizedVolume = (VolumeVO) vol;
81178117

8118-
if (userVmDetailsDao.findDetail(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE) == null && !vol.getSize().equals(template.getSize())) {
8119-
if (template.getSize() != null) {
8118+
if (template != null && template.getSize() != null) {
8119+
UserVmDetailVO vmRootDiskSizeDetail = userVmDetailsDao.findDetail(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE);
8120+
if (vmRootDiskSizeDetail == null) {
81208121
resizedVolume.setSize(template.getSize());
8122+
} else {
8123+
long rootDiskSize = Long.parseLong(vmRootDiskSizeDetail.getValue()) * GiB_TO_BYTES;
8124+
if (template.getSize() >= rootDiskSize) {
8125+
resizedVolume.setSize(template.getSize());
8126+
userVmDetailsDao.remove(vmRootDiskSizeDetail.getId());
8127+
} else {
8128+
resizedVolume.setSize(rootDiskSize);
8129+
}
81218130
}
81228131
}
81238132

81248133
if (diskOffering != null) {
81258134
resizedVolume.setDiskOfferingId(diskOffering.getId());
8126-
resizedVolume.setSize(diskOffering.getDiskSize());
8127-
if (diskOffering.isCustomized()) {
8128-
resizedVolume.setSize(vol.getSize());
8135+
if (!diskOffering.isCustomized()) {
8136+
resizedVolume.setSize(diskOffering.getDiskSize());
81298137
}
81308138
if (diskOffering.getMinIops() != null) {
81318139
resizedVolume.setMinIops(diskOffering.getMinIops());
@@ -8139,6 +8147,14 @@ private void updateVolume(Volume vol, VMTemplateVO template, UserVmVO userVm, Di
81398147
if (StringUtils.isNumeric(details.get(VmDetailConstants.ROOT_DISK_SIZE))) {
81408148
Long rootDiskSize = Long.parseLong(details.get(VmDetailConstants.ROOT_DISK_SIZE)) * GiB_TO_BYTES;
81418149
resizedVolume.setSize(rootDiskSize);
8150+
UserVmDetailVO vmRootDiskSizeDetail = userVmDetailsDao.findDetail(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE);
8151+
if (vmRootDiskSizeDetail != null) {
8152+
vmRootDiskSizeDetail.setValue(details.get(VmDetailConstants.ROOT_DISK_SIZE));
8153+
userVmDetailsDao.update(vmRootDiskSizeDetail.getId(), vmRootDiskSizeDetail);
8154+
} else {
8155+
userVmDetailsDao.persist(new UserVmDetailVO(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE,
8156+
details.get(VmDetailConstants.ROOT_DISK_SIZE), true));
8157+
}
81428158
}
81438159

81448160
String minIops = details.get(MIN_IOPS);

ui/src/config/section/compute.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ export default {
612612
groupAction: true,
613613
popup: true,
614614
args: (record, store, group) => {
615+
if (record.clustertype === 'CloudManaged') {
616+
return []
617+
}
615618
return (['Admin'].includes(store.userInfo.roletype) || store.features.allowuserexpungerecovervm)
616619
? ['cleanup', 'expunge'] : ['cleanup']
617620
},

0 commit comments

Comments
 (0)