Skip to content

Commit 7ca4582

Browse files
bwswyadvr
authored andcommitted
CLOUDSTACK-10188 - Resource Accounting for primary storage is Broken when Domains are in use (#2362)
During storage expunge domain resource statistics for primary storage space resource counter is not updated for domain. This leads to the situation when domain resource statistics for primary storage is overfilled (statistics only increase but not decrease). Global scheduled task resourcecount.check.interval > 0 provides a workaround but not fixes the problem truly because when accounts inside domains use primary_storage allocation/deallocation intensively it leads to service block of operation. NB: Unable to implement marvin tests because it (marvin) places in database weird primary storage volume size of 100 when creating VM from template. It might be a sign of opening a new issue for that bug.
1 parent 64832fd commit 7ca4582

File tree

6 files changed

+228
-203
lines changed

6 files changed

+228
-203
lines changed

api/src/com/cloud/user/ResourceLimitService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public interface ResourceLimitService {
2929

3030
static final ConfigKey<Long> ResourceCountCheckInterval = new ConfigKey<Long>("Advanced", Long.class, "resourcecount.check.interval", "300",
31-
"Time (in seconds) to wait before retrying resource count check task. Default is 300, Setting this to 0 will not run the task", false);
31+
"Time (in seconds) to wait before running resource recalculation and fixing task. Default is 300 seconds, Setting this to 0 disables execution of the task", false);
3232

3333
/**
3434
* Updates an existing resource limit with the specified details. If a limit doesn't exist, will create one.

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,8 +1576,7 @@ public void destroyVolume(Volume volume) {
15761576
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(),
15771577
Volume.class.getName(), volume.getUuid(), volume.isDisplayVolume());
15781578
_resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.volume, volume.isDisplay());
1579-
//FIXME - why recalculate and not decrement
1580-
_resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(), ResourceType.primary_storage.getOrdinal());
1579+
_resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.isDisplay(), new Long(volume.getSize()));
15811580
} catch (Exception e) {
15821581
s_logger.debug("Failed to destroy volume" + volume.getId(), e);
15831582
throw new CloudRuntimeException("Failed to destroy volume" + volume.getId(), e);

0 commit comments

Comments
 (0)