add support to revert snapshot for clvm

This commit is contained in:
Pearl Dsilva 2026-02-20 07:50:55 -05:00
parent ab98daa19d
commit 6f2011374f
1 changed files with 33 additions and 0 deletions

View File

@ -643,6 +643,11 @@ public class DefaultSnapshotStrategy extends SnapshotStrategyBase {
return StrategyPriority.DEFAULT;
}
// Check if this is a CLVM volume with snapshot backed up to secondary storage
if (isSnapshotStoredOnSecondaryForCLVMVolume(snapshot, volumeVO)) {
return StrategyPriority.DEFAULT;
}
return StrategyPriority.CANT_HANDLE;
}
if (zoneId != null && SnapshotOperation.DELETE.equals(op)) {
@ -691,4 +696,32 @@ public class DefaultSnapshotStrategy extends SnapshotStrategyBase {
dataStoreMgr.getStoreZoneId(s.getDataStoreId(), s.getRole()), volumeVO.getDataCenterId()));
}
/**
* Checks if a CLVM volume snapshot is stored on secondary storage in the same zone.
* CLVM snapshots are backed up to secondary storage and removed from primary storage.
*/
protected boolean isSnapshotStoredOnSecondaryForCLVMVolume(Snapshot snapshot, VolumeVO volumeVO) {
if (volumeVO == null) {
return false;
}
Long poolId = volumeVO.getPoolId();
if (poolId == null) {
return false;
}
StoragePool pool = (StoragePool) dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
if (pool == null || pool.getPoolType() != StoragePoolType.CLVM) {
return false;
}
List<SnapshotDataStoreVO> snapshotStores = snapshotStoreDao.listReadyBySnapshot(snapshot.getId(), DataStoreRole.Image);
if (CollectionUtils.isEmpty(snapshotStores)) {
return false;
}
return snapshotStores.stream().anyMatch(s -> Objects.equals(
dataStoreMgr.getStoreZoneId(s.getDataStoreId(), s.getRole()), volumeVO.getDataCenterId()));
}
}