@@ -1694,9 +1694,14 @@ 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 (volume .getDataCenterId ()) ||
1699+ Snapshot .LocationType .PRIMARY .equals (locationType )) {
1700+ storeResourceType = ResourceType .primary_storage ;
1701+ }
16971702 try {
16981703 _resourceLimitMgr .checkResourceLimit (owner , ResourceType .snapshot );
1699- _resourceLimitMgr .checkResourceLimit (owner , ResourceType . secondary_storage , new Long ( volume .getSize ()). longValue ());
1704+ _resourceLimitMgr .checkResourceLimit (owner , storeResourceType , volume .getSize ());
17001705 } catch (ResourceAllocationException e ) {
17011706 if (snapshotType != Type .MANUAL ) {
17021707 String msg = String .format ("Snapshot resource limit exceeded for account %s. Failed to create recurring snapshots" , owner );
@@ -1747,7 +1752,7 @@ public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName,
17471752 }
17481753 CallContext .current ().putContextParameter (Snapshot .class , snapshot .getUuid ());
17491754 _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType .snapshot );
1750- _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType . secondary_storage , new Long ( volume .getSize () ));
1755+ _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), storeResourceType , volume .getSize ());
17511756 return snapshot ;
17521757 }
17531758
0 commit comments