From f7b95cd8f06af5eea36716aaae0e6a25fcc8833c Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 29 Apr 2024 10:54:03 +0200 Subject: [PATCH 1/2] UI: hide Cleanup/Expunge when delete a CloudManaged CKS cluster (#8593) --- ui/src/config/section/compute.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index db17b20ef9dc..7a0644ba98f3 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -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'] }, From 027149487b509be5cccef1b8ea73de7707bc35d7 Mon Sep 17 00:00:00 2001 From: Vishesh Date: Mon, 29 Apr 2024 22:15:06 +0530 Subject: [PATCH 2/2] Fix: Update rootdisksize detail on restore VM (#8981) * Fix: Update rootdisksize detail on restore VM * minor fixup --- .../java/com/cloud/vm/UserVmManagerImpl.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index e574d9887c3f..4283b44e171e 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -7975,17 +7975,25 @@ public Pair doInTransaction(final TransactionStatus status) th private void updateVolume(Volume vol, VMTemplateVO template, UserVmVO userVm, DiskOffering diskOffering, Map 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()); @@ -7999,6 +8007,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);