Skip to content

Commit bdae23e

Browse files
authored
Fix listing disk offerings for newly created VMs that haven't yet been started (apache#10476)
1 parent 2d00933 commit bdae23e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6071,6 +6071,9 @@ protected boolean isDiskOfferingSuitableForVm(VMInstanceVO vm, VirtualMachinePro
60716071
@Override
60726072
public Map<Long, Boolean> getDiskOfferingSuitabilityForVm(long vmId, List<Long> diskOfferingIds) {
60736073
VMInstanceVO vm = _vmDao.findById(vmId);
6074+
if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.DEPLOY_VM) != null) {
6075+
return new HashMap<>();
6076+
}
60746077
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
60756078
Pair<Long, Long> clusterAndHost = findClusterAndHostIdForVm(vm, false);
60766079
Long clusterId = clusterAndHost.first();

server/src/main/java/com/cloud/api/ApiDBUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ public static List<DiskOfferingResponse> newDiskOfferingResponses(Long vmId, Lis
21372137
for (DiskOfferingJoinVO offering : offerings) {
21382138
DiskOfferingResponse response = s_diskOfferingJoinDao.newDiskOfferingResponse(offering);
21392139
if (vmId != null) {
2140-
response.setSuitableForVm(suitability.get(offering.getId()));
2140+
response.setSuitableForVm(suitability.getOrDefault(offering.getId(), true));
21412141
}
21422142
list.add(response);
21432143
}

0 commit comments

Comments
 (0)