@@ -1696,9 +1696,14 @@ public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName,
16961696 Type snapshotType = getSnapshotType (policyId );
16971697 Account owner = _accountMgr .getAccount (volume .getAccountId ());
16981698
1699+ ResourceType storeResourceType = ResourceType .secondary_storage ;
1700+ if (!isBackupSnapshotToSecondaryForZone (volume .getDataCenterId ()) ||
1701+ Snapshot .LocationType .PRIMARY .equals (locationType )) {
1702+ storeResourceType = ResourceType .primary_storage ;
1703+ }
16991704 try {
17001705 _resourceLimitMgr .checkResourceLimit (owner , ResourceType .snapshot );
1701- _resourceLimitMgr .checkResourceLimit (owner , ResourceType . secondary_storage , new Long ( volume .getSize ()). longValue ());
1706+ _resourceLimitMgr .checkResourceLimit (owner , storeResourceType , volume .getSize ());
17021707 } catch (ResourceAllocationException e ) {
17031708 if (snapshotType != Type .MANUAL ) {
17041709 String msg = String .format ("Snapshot resource limit exceeded for account %s. Failed to create recurring snapshots" , owner );
@@ -1749,7 +1754,7 @@ public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName,
17491754 }
17501755 CallContext .current ().putContextParameter (Snapshot .class , snapshot .getUuid ());
17511756 _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType .snapshot );
1752- _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType . secondary_storage , new Long ( volume .getSize () ));
1757+ _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), storeResourceType , volume .getSize ());
17531758 return snapshot ;
17541759 }
17551760
0 commit comments