Bug-Id: CS-39350 Able to upload Volume greater than the Resource limit defined for Primary Storage.
Reviewed-By: Harikrishna Patnala <harikrishna.patn...@citrix.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f172fbef Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f172fbef Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f172fbef Branch: refs/heads/master Commit: f172fbef8aa2170efd63458cbcefc12652c5f2bc Parents: a7e511c Author: Rajani Karuturi <rajanikarut...@gmail.com> Authored: Mon Apr 20 12:57:31 2015 +0530 Committer: Rajani Karuturi <rajanikarut...@gmail.com> Committed: Mon Apr 20 13:01:19 2015 +0530 ---------------------------------------------------------------------- server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java | 6 ++++++ server/src/com/cloud/storage/VolumeApiServiceImpl.java | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f172fbef/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java b/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java index 01bda4f..84b33d2 100755 --- a/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java +++ b/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java @@ -26,6 +26,8 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.configuration.Resource; +import com.cloud.user.ResourceLimitService; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; @@ -92,6 +94,8 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto private EndPointSelector _epSelector; @Inject private DataStoreManager storeMgr; + @Inject + ResourceLimitService _resourceLimitMgr; private long _nodeId; private ScheduledExecutorService _executor = null; @@ -285,6 +289,7 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto volumeUpdate.setSize(answer.getVirtualSize()); _volumeDao.update(tmpVolume.getId(), volumeUpdate); stateMachine.transitTo(tmpVolume, Event.OperationSucceeded, null, _volumeDao); + _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), Resource.ResourceType.secondary_storage, answer.getVirtualSize()); if (s_logger.isDebugEnabled()) { s_logger.debug("Volume " + tmpVolume.getUuid() + " uploaded successfully"); @@ -358,6 +363,7 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto templateUpdate.setSize(answer.getVirtualSize()); _templateDao.update(tmpTemplate.getId(), templateUpdate); stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationSucceeded, null, _templateDao); + _resourceLimitMgr.incrementResourceCount(template.getAccountId(), Resource.ResourceType.secondary_storage, answer.getVirtualSize()); if (s_logger.isDebugEnabled()) { s_logger.debug("Template " + tmpTemplate.getUuid() + " uploaded successfully"); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f172fbef/server/src/com/cloud/storage/VolumeApiServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 2022dde..d7000f7 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -456,8 +456,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic //url can be null incase of postupload if(url!=null) { _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, UriUtils.getRemoteSize(url)); - } else { - _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage); } return volume;