Skip to content

Commit

Permalink
Merge release branch 4.19 to main
Browse files Browse the repository at this point in the history
* 4.19:
  Fix: Update rootdisksize detail on restore VM (#8981)
  UI: hide Cleanup/Expunge when delete a CloudManaged CKS cluster (#8593)
  • Loading branch information
DaanHoogland committed Apr 30, 2024
2 parents db572f4 + 0271494 commit d5241d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
26 changes: 21 additions & 5 deletions server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8115,17 +8115,25 @@ public Pair<UserVmVO, Volume> doInTransaction(final TransactionStatus status) th
private void updateVolume(Volume vol, VMTemplateVO template, UserVmVO userVm, DiskOffering diskOffering, Map<String, String> details) {
VolumeVO resizedVolume = (VolumeVO) vol;

if (userVmDetailsDao.findDetail(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE) == null && !vol.getSize().equals(template.getSize())) {
if (template.getSize() != null) {
if (template != null && template.getSize() != null) {
UserVmDetailVO vmRootDiskSizeDetail = userVmDetailsDao.findDetail(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE);
if (vmRootDiskSizeDetail == null) {
resizedVolume.setSize(template.getSize());
} else {
long rootDiskSize = Long.parseLong(vmRootDiskSizeDetail.getValue()) * GiB_TO_BYTES;
if (template.getSize() >= rootDiskSize) {
resizedVolume.setSize(template.getSize());
userVmDetailsDao.remove(vmRootDiskSizeDetail.getId());
} else {
resizedVolume.setSize(rootDiskSize);
}
}
}

if (diskOffering != null) {
resizedVolume.setDiskOfferingId(diskOffering.getId());
resizedVolume.setSize(diskOffering.getDiskSize());
if (diskOffering.isCustomized()) {
resizedVolume.setSize(vol.getSize());
if (!diskOffering.isCustomized()) {
resizedVolume.setSize(diskOffering.getDiskSize());
}
if (diskOffering.getMinIops() != null) {
resizedVolume.setMinIops(diskOffering.getMinIops());
Expand All @@ -8139,6 +8147,14 @@ private void updateVolume(Volume vol, VMTemplateVO template, UserVmVO userVm, Di
if (StringUtils.isNumeric(details.get(VmDetailConstants.ROOT_DISK_SIZE))) {
Long rootDiskSize = Long.parseLong(details.get(VmDetailConstants.ROOT_DISK_SIZE)) * GiB_TO_BYTES;
resizedVolume.setSize(rootDiskSize);
UserVmDetailVO vmRootDiskSizeDetail = userVmDetailsDao.findDetail(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE);
if (vmRootDiskSizeDetail != null) {
vmRootDiskSizeDetail.setValue(details.get(VmDetailConstants.ROOT_DISK_SIZE));
userVmDetailsDao.update(vmRootDiskSizeDetail.getId(), vmRootDiskSizeDetail);
} else {
userVmDetailsDao.persist(new UserVmDetailVO(userVm.getId(), VmDetailConstants.ROOT_DISK_SIZE,
details.get(VmDetailConstants.ROOT_DISK_SIZE), true));
}
}

String minIops = details.get(MIN_IOPS);
Expand Down
3 changes: 3 additions & 0 deletions ui/src/config/section/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ export default {
groupAction: true,
popup: true,
args: (record, store, group) => {
if (record.clustertype === 'CloudManaged') {
return []
}
return (['Admin'].includes(store.userInfo.roletype) || store.features.allowuserexpungerecovervm)
? ['cleanup', 'expunge'] : ['cleanup']
},
Expand Down

0 comments on commit d5241d3

Please sign in to comment.