abh1sar commented on code in PR #12481:
URL: https://github.com/apache/cloudstack/pull/12481#discussion_r2711917090
##########
engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDaoImpl.java:
##########
@@ -78,6 +78,15 @@ public class SnapshotDataStoreDaoImpl extends
GenericDaoBase<SnapshotDataStoreVO
" order by created %s " +
" limit 1";
+ private static final String
GET_PHYSICAL_SIZE_OF_SNAPSHOTS_ON_PRIMARY_BY_ACCOUNT = "SELECT
SUM(s.physical_size) " +
+ "FROM cloud.snapshot_store_ref s " +
+ "LEFT JOIN cloud.snapshots ON s.snapshot_id = snapshots.id " +
+ "WHERE snapshots.account_id = ? " +
+ "AND snapshots.removed IS NULL " +
+ "AND s.state = 'Ready' " +
+ "AND s.store_role = 'Primary' " +
+ "AND NOT EXISTS (SELECT 1 FROM cloud.snapshot_store_ref i WHERE
i.snapshot_id = s.snapshot_id AND i.store_role = 'Image')";
Review Comment:
Shouldn't we include the size of the snapshot in primary which is present on
secondary as well?
```suggestion
private static final String
GET_PHYSICAL_SIZE_OF_SNAPSHOTS_ON_PRIMARY_BY_ACCOUNT = "SELECT
SUM(s.physical_size) " +
"FROM cloud.snapshot_store_ref s " +
"LEFT JOIN cloud.snapshots ON s.snapshot_id = snapshots.id " +
"WHERE snapshots.account_id = ? " +
"AND snapshots.removed IS NULL " +
"AND s.state = 'Ready' " +
"AND s.store_role = 'Primary' ";
```
##########
engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDaoImpl.java:
##########
@@ -78,6 +78,15 @@ public class SnapshotDataStoreDaoImpl extends
GenericDaoBase<SnapshotDataStoreVO
" order by created %s " +
" limit 1";
+ private static final String
GET_PHYSICAL_SIZE_OF_SNAPSHOTS_ON_PRIMARY_BY_ACCOUNT = "SELECT
SUM(s.physical_size) " +
+ "FROM cloud.snapshot_store_ref s " +
+ "LEFT JOIN cloud.snapshots ON s.snapshot_id = snapshots.id " +
+ "WHERE snapshots.account_id = ? " +
+ "AND snapshots.removed IS NULL " +
+ "AND s.state = 'Ready' " +
+ "AND s.store_role = 'Primary' " +
+ "AND NOT EXISTS (SELECT 1 FROM cloud.snapshot_store_ref i WHERE
i.snapshot_id = s.snapshot_id AND i.store_role = 'Image')";
Review Comment:
Actually, if we are going this way we can just use `snapshotSizeSearch` in
`ResourceLimitManagerImpl` directly similar to
calculateSecondaryStorageForAccount()
```
SearchCriteria<SumCount> sc2 = snapshotSizeSearch.create();
sc2.setParameters("state",
ObjectInDataStoreStateMachine.State.Ready);
sc2.setParameters("storeRole", DataStoreRole.Primary);
sc2.setJoinParameters("snapshots", "accountId", accountId);
List<SumCount> snapshots = _snapshotDataStoreDao.customSearch(sc2,
null);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]