Skip to content

Commit 87600bc

Browse files
committed
server: check limit on correct store during snapshot allocation
Fixes #1151 Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 973b333 commit 87600bc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,9 +1694,13 @@ public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName,
16941694
Type snapshotType = getSnapshotType(policyId);
16951695
Account owner = _accountMgr.getAccount(volume.getAccountId());
16961696

1697+
ResourceType storeResourceType = ResourceType.secondary_storage;
1698+
if (!isBackupSnapshotToSecondaryForZone(zoneIds.get(0)) || Snapshot.LocationType.PRIMARY.equals(locationType)) {
1699+
storeResourceType = ResourceType.primary_storage;
1700+
}
16971701
try {
16981702
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.snapshot);
1699-
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.secondary_storage, new Long(volume.getSize()).longValue());
1703+
_resourceLimitMgr.checkResourceLimit(owner, storeResourceType, volume.getSize());
17001704
} catch (ResourceAllocationException e) {
17011705
if (snapshotType != Type.MANUAL) {
17021706
String msg = String.format("Snapshot resource limit exceeded for account %s. Failed to create recurring snapshots", owner);
@@ -1747,7 +1751,7 @@ public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName,
17471751
}
17481752
CallContext.current().putContextParameter(Snapshot.class, snapshot.getUuid());
17491753
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.snapshot);
1750-
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, new Long(volume.getSize()));
1754+
_resourceLimitMgr.incrementResourceCount(volume.getAccountId(), storeResourceType, volume.getSize());
17511755
return snapshot;
17521756
}
17531757

0 commit comments

Comments
 (0)