JoaoJandre commented on code in PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#discussion_r1979561857
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -390,10 +390,19 @@ public Snapshot revertSnapshot(Long snapshotId) {
boolean result = snapshotStrategy.revertSnapshot(snapshotInfo);
if (result) {
+ Long differenceBetweenVolumeAndSnapshotSize = new
Long(volume.getSize() - snapshot.getSize());
// update volume size and primary storage count
- _resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(),
ResourceType.primary_storage, new Long(volume.getSize() - snapshot.getSize()));
- volume.setSize(snapshot.getSize());
- _volsDao.update(volume.getId(), volume);
+ if (differenceBetweenVolumeAndSnapshotSize != 0) {
+ if (differenceBetweenVolumeAndSnapshotSize > 0) {
+
_resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(),
ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize);
+ } else if (differenceBetweenVolumeAndSnapshotSize < 0) {
+
_resourceLimitMgr.incrementResourceCount(snapshot.getAccountId(),
ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize * -1L);
+ }
+ volume.setSize(snapshot.getSize());
+ _volsDao.update(volume.getId(), volume);
+
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_RESIZE,
volume.getAccountId(), volume.getDataCenterId(), volume.getId(),
volume.getName(),
+ volume.getDiskOfferingId(), volume.getTemplateId(),
volume.getSize(), Volume.class.getName(), volume.getUuid());
+ }
Review Comment:
+1 on creating a new method for it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]