Skip to content

Commit 08d4581

Browse files
committed
Handle inactive disk offering edge case
1 parent ac96d06 commit 08d4581

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ public List<DiskOfferingInfo> getDataDiskOfferingListFromBackup(Backup backup) {
875875
continue;
876876
}
877877
DiskOfferingVO diskOffering = diskOfferingDao.findByUuid(diskOfferingIds[i]);
878-
if (diskOffering == null) {
878+
if (diskOffering == null || diskOffering.getState().equals(DiskOffering.State.Inactive)) {
879879
throw new CloudRuntimeException("Unable to find the disk offering with uuid (" + diskOfferingIds[i] + ") stored in backup. Please specify a valid disk offering id while creating the instance");
880880
}
881881
Long size = Long.parseLong(diskSizes[i]) / (1024 * 1024 * 1024);
@@ -951,7 +951,7 @@ public boolean restoreBackupToVM(final Long backupId, final Long vmId) throws Re
951951
vm.getId(), ApiCommandResourceType.VirtualMachine.toString(), eventId);
952952
throw new CloudRuntimeException(String.format("Error restoring backup [%s] to VM %s.", backupDetailsInMessage));
953953
}
954-
} catch (Exception e) {
954+
} catch (CloudRuntimeException e) {
955955
updateVolumeState(vm, Volume.Event.RestoreFailed, Volume.State.Ready);
956956
updateVmState(vm, VirtualMachine.Event.RestoringFailed, VirtualMachine.State.Stopped);
957957
logger.error(String.format("Failed to restore backup [%s] to VM %s due to: [%s].", backupDetailsInMessage, vm.getInstanceName(), e.getMessage()), e);

ui/src/views/compute/wizard/VolumeDiskOfferingSelectView.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@
3333
<span>
3434
<a-select
3535
@change="updateOfferingSelect($event, record.id)"
36-
:defaultValue="record.diskofferingid"
36+
:defaultValue="getDefaultDiskOffering(record)"
3737
showSearch
3838
optionFilterProp="label"
3939
:filterOption="(input, option) => {
4040
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
41-
}" >
41+
}"
42+
:style="{ width: '80%' }" >
4243
<a-select-option v-for="offering in diskOfferings" :key="offering.id" :label="offering.displaytext">
4344
{{ offering.displaytext }}
4445
</a-select-option>
@@ -193,6 +194,9 @@ export default {
193194
this.setDefaultValues()
194195
this.loading = false
195196
},
197+
getDefaultDiskOffering (record) {
198+
return this.diskOfferings.find(x => x.id === record.diskofferingid)?.id || this.diskOfferings[0]?.id
199+
},
196200
setDefaultValues () {
197201
this.values = {}
198202
for (const item of this.items) {

0 commit comments

Comments
 (0)