Skip to content

Commit a8ee45d

Browse files
sudisonminchen07
authored andcommitted
CLOUDSTACK-4074: if hypervisor doesn't return size of volume/template, don't update it into db
1 parent ec89e23 commit a8ee45d

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class VolumeObjectTO implements DataTO {
3030
private Volume.Type volumeType;
3131
private DataStoreTO dataStore;
3232
private String name;
33-
private long size;
33+
private Long size;
3434
private String path;
3535
private Long volumeId;
3636
private String vmName;
@@ -108,7 +108,7 @@ public String getName() {
108108
return this.name;
109109
}
110110

111-
public long getSize() {
111+
public Long getSize() {
112112
return this.size;
113113
}
114114

‎engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,15 +564,19 @@ public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer a
564564
VolumeVO vol = this.volumeDao.findById(this.getId());
565565
VolumeObjectTO newVol = (VolumeObjectTO) cpyAnswer.getNewData();
566566
vol.setPath(newVol.getPath());
567-
vol.setSize(newVol.getSize());
567+
if (newVol.getSize() != null) {
568+
vol.setSize(newVol.getSize());
569+
}
568570
vol.setPoolId(this.getDataStore().getId());
569571
volumeDao.update(vol.getId(), vol);
570572
} else if (answer instanceof CreateObjectAnswer) {
571573
CreateObjectAnswer createAnswer = (CreateObjectAnswer) answer;
572574
VolumeObjectTO newVol = (VolumeObjectTO) createAnswer.getData();
573575
VolumeVO vol = this.volumeDao.findById(this.getId());
574576
vol.setPath(newVol.getPath());
575-
vol.setSize(newVol.getSize());
577+
if (newVol.getSize() != null) {
578+
vol.setSize(newVol.getSize());
579+
}
576580
vol.setPoolId(this.getDataStore().getId());
577581
volumeDao.update(vol.getId(), vol);
578582
}

‎plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ public Answer createTemplateFromSnapshot(CopyCommand cmd) {
943943

944944
TemplateObjectTO newTemplate = new TemplateObjectTO();
945945
newTemplate.setPath(result.first());
946-
newTemplate.setSize(result.second());
946+
newTemplate.setSize(result.third());
947947
newTemplate.setFormat(ImageFormat.OVA);
948948
return new CopyCmdAnswer(newTemplate);
949949
} catch (Throwable e) {
@@ -1651,12 +1651,11 @@ public Answer createVolumeFromSnapshot(CopyCommand cmd) {
16511651
}
16521652

16531653
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
1654-
Long size = restoreVolumeFromSecStorage(hyperHost, primaryDsMo,
1654+
restoreVolumeFromSecStorage(hyperHost, primaryDsMo,
16551655
newVolumeName, secondaryStorageUrl, backupPath, backedUpSnapshotUuid);
16561656

16571657
VolumeObjectTO newVol = new VolumeObjectTO();
16581658
newVol.setPath(newVolumeName);
1659-
newVol.setSize(size);
16601659
return new CopyCmdAnswer(newVol);
16611660
} catch (Throwable e) {
16621661
if (e instanceof RemoteException) {

0 commit comments

Comments
 (0)