Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ public Pair<List<String>, Set<String>> getVolumeCheckpointPathsAndImageStoreUrls
Set<Long> imageStoreIds = new HashSet<>();
Set<String> imageStoreUrls = new HashSet<>();
if (HypervisorType.KVM.equals(hypervisorType)) {
List<SnapshotDataStoreVO> snapshotDataStoreVos = _snapshotDataStoreDao.listReadyByVolumeIdAndCheckpointPathNotNull(volumeId);
List<SnapshotDataStoreVO> snapshotDataStoreVos = _snapshotDataStoreDao.listReadyOrHiddenByVolumeIdAndCheckpointPathNotNull(volumeId);
snapshotDataStoreVos.forEach(snapshotDataStoreVO -> {
checkpointPaths.add(snapshotDataStoreVO.getKvmCheckpointPath());
if (DataStoreRole.Image.equals(snapshotDataStoreVO.getRole())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public void getVolumeCheckpointPathsAndImageStoreUrlsTestReturnCheckpointIfKVM()
snapshotDataStoreVO.setKvmCheckpointPath("Test");
snapshotDataStoreVO.setRole(DataStoreRole.Primary);

Mockito.doReturn(List.of(snapshotDataStoreVO)).when(snapshotDataStoreDaoMock).listReadyByVolumeIdAndCheckpointPathNotNull(Mockito.anyLong());
Mockito.doReturn(List.of(snapshotDataStoreVO)).when(snapshotDataStoreDaoMock).listReadyOrHiddenByVolumeIdAndCheckpointPathNotNull(Mockito.anyLong());

Pair<List<String>, Set<String>> result = volumeOrchestrator.getVolumeCheckpointPathsAndImageStoreUrls(0, Hypervisor.HypervisorType.KVM);

Expand All @@ -656,7 +656,7 @@ public void getVolumeCheckpointPathsAndImageStoreUrlsTestReturnCheckpointIfKVMAn
snapshotDataStoreVO.setRole(DataStoreRole.Image);
snapshotDataStoreVO.setDataStoreId(13);

Mockito.doReturn(List.of(snapshotDataStoreVO)).when(snapshotDataStoreDaoMock).listReadyByVolumeIdAndCheckpointPathNotNull(Mockito.anyLong());
Mockito.doReturn(List.of(snapshotDataStoreVO)).when(snapshotDataStoreDaoMock).listReadyOrHiddenByVolumeIdAndCheckpointPathNotNull(Mockito.anyLong());

ImageStoreVO imageStoreVO = new ImageStoreVO();
imageStoreVO.setUrl("URL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Lo

List<SnapshotDataStoreVO> listBySnapshotIdAndDataStoreRoleAndStateIn(long snapshotId, DataStoreRole role, ObjectInDataStoreStateMachine.State... state);

List<SnapshotDataStoreVO> listReadyByVolumeIdAndCheckpointPathNotNull(long volumeId);
List<SnapshotDataStoreVO> listReadyOrHiddenByVolumeIdAndCheckpointPathNotNull(long volumeId);

SnapshotDataStoreVO findOneBySnapshotId(long snapshotId, long zoneId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
private SearchBuilder<SnapshotDataStoreVO> storeAndSnapshotIdsSearch;
private SearchBuilder<SnapshotDataStoreVO> storeSnapshotDownloadStatusSearch;
private SearchBuilder<SnapshotDataStoreVO> searchFilteringStoreIdInVolumeIdEqStoreRoleEqStateEqKVMCheckpointNotNull;
private SearchBuilder<SnapshotDataStoreVO> searchVolumeIdEqStateInKVMCheckpointNotNull;
private SearchBuilder<SnapshotDataStoreVO> searchFilterStateAndDownloadUrlNotNullAndDownloadUrlCreatedBefore;
private SearchBuilder<SnapshotDataStoreVO> searchFilteringStoreIdInVolumeIdEqStoreRoleEqStateEqPathEq;

Expand Down Expand Up @@ -207,6 +208,12 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
searchFilteringStoreIdInVolumeIdEqStoreRoleEqStateEqKVMCheckpointNotNull.and(STORE_ID, searchFilteringStoreIdInVolumeIdEqStoreRoleEqStateEqKVMCheckpointNotNull.entity().getDataStoreId(), SearchCriteria.Op.IN);
searchFilteringStoreIdInVolumeIdEqStoreRoleEqStateEqKVMCheckpointNotNull.done();

searchVolumeIdEqStateInKVMCheckpointNotNull = createSearchBuilder();
searchVolumeIdEqStateInKVMCheckpointNotNull.and(VOLUME_ID, searchVolumeIdEqStateInKVMCheckpointNotNull.entity().getVolumeId(), SearchCriteria.Op.EQ);
searchVolumeIdEqStateInKVMCheckpointNotNull.and(STATE, searchVolumeIdEqStateInKVMCheckpointNotNull.entity().getState(), SearchCriteria.Op.IN);
searchVolumeIdEqStateInKVMCheckpointNotNull.and(KVM_CHECKPOINT_PATH, searchVolumeIdEqStateInKVMCheckpointNotNull.entity().getKvmCheckpointPath(), SearchCriteria.Op.NNULL);
searchVolumeIdEqStateInKVMCheckpointNotNull.done();

searchFilterStateAndDownloadUrlNotNullAndDownloadUrlCreatedBefore = createSearchBuilder();
searchFilterStateAndDownloadUrlNotNullAndDownloadUrlCreatedBefore.and(STATE, searchFilterStateAndDownloadUrlNotNullAndDownloadUrlCreatedBefore.entity().getState(), SearchCriteria.Op.EQ);
searchFilterStateAndDownloadUrlNotNullAndDownloadUrlCreatedBefore.and(DOWNLOAD_URL, searchFilterStateAndDownloadUrlNotNullAndDownloadUrlCreatedBefore.entity().getExtractUrl(), SearchCriteria.Op.NNULL);
Expand Down Expand Up @@ -714,11 +721,11 @@ protected boolean isSnapshotChainingRequired(long volumeId, boolean kvmIncrement
}

@Override
public List<SnapshotDataStoreVO> listReadyByVolumeIdAndCheckpointPathNotNull(long volumeId) {
SearchCriteria<SnapshotDataStoreVO> sc = searchFilteringStoreIdInVolumeIdEqStoreRoleEqStateEqKVMCheckpointNotNull.create();
public List<SnapshotDataStoreVO> listReadyOrHiddenByVolumeIdAndCheckpointPathNotNull(long volumeId) {
SearchCriteria<SnapshotDataStoreVO> sc = searchVolumeIdEqStateInKVMCheckpointNotNull.create();
sc.setParameters(VOLUME_ID, volumeId);
sc.setParameters(STATE, State.Ready);
return listBy(sc);
sc.setParameters(STATE, State.Ready, State.Hidden);
return listBy(sc, new Filter(SnapshotDataStoreVO.class, "id", true, null, null));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public StrategyPriority canHandle(Long vmId, Long rootPoolId, boolean snapshotMe
}

for (VolumeVO volume : volumeDao.findByInstance(vmId)) {
List<SnapshotDataStoreVO> snapshots = snapshotDataStoreDao.listReadyByVolumeIdAndCheckpointPathNotNull(volume.getId());
List<SnapshotDataStoreVO> snapshots = snapshotDataStoreDao.listReadyOrHiddenByVolumeIdAndCheckpointPathNotNull(volume.getId());
if (CollectionUtils.isNotEmpty(snapshots)) {
logger.debug(
"{} as VM has a volume with incremental snapshots {}. Incremental volume snapshots and StorageVmSnapshotStrategy are not compatible," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,12 @@ protected EndPoint getEndPointForBitmapRemoval(DataObject object, boolean encryp
VirtualMachine attachedVM = volumeInfo.getAttachedVM();
if (attachedVM.getHostId() != null) {
return getEndPointFromHostId(attachedVM.getHostId());
} else if (attachedVM.getLastHostId() != null) {
}
EndPoint clvmEp = tryRouteToClvmLockHolder(volumeInfo, _storagePoolDao.findById(volumeInfo.getPoolId()), "bitmap removal");
if (clvmEp != null) {
return clvmEp;
}
if (attachedVM.getLastHostId() != null) {
return getEndPointFromHostId(attachedVM.getLastHostId());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,51 @@
Mockito.verify(defaultEndPointSelectorSpy, Mockito.times(1)).select(volumeInfoMock, false);
}

private void mockClvmVolumeOfStoppedVm(Long lockHostId) {
Mockito.doReturn(STORE_ID).when(volumeInfoMock).getPoolId();

Check warning on line 177 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bK&open=AaHSLmEtussJYe4A13bK&pullRequest=14484
Mockito.when(_storagePoolDao.findById(STORE_ID)).thenReturn(storagePoolVOMock);

Check warning on line 178 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "when".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bL&open=AaHSLmEtussJYe4A13bL&pullRequest=14484
Mockito.when(storagePoolVOMock.getPoolType()).thenReturn(StoragePoolType.CLVM_NG);

Check warning on line 179 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "when".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bM&open=AaHSLmEtussJYe4A13bM&pullRequest=14484
Mockito.doReturn(lockHostId).when(defaultEndPointSelectorSpy).getClvmLockHostId(volumeInfoMock);

Check warning on line 180 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bN&open=AaHSLmEtussJYe4A13bN&pullRequest=14484
Mockito.doReturn(true).when(volumeInfoMock).isAttachedVM();

Check warning on line 181 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bO&open=AaHSLmEtussJYe4A13bO&pullRequest=14484
Mockito.doReturn(virtualMachineMock).when(volumeInfoMock).getAttachedVM();

Check warning on line 182 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bP&open=AaHSLmEtussJYe4A13bP&pullRequest=14484
Mockito.doReturn(null).when(virtualMachineMock).getHostId();

Check warning on line 183 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bQ&open=AaHSLmEtussJYe4A13bQ&pullRequest=14484
Mockito.doReturn(HOST_ID).when(virtualMachineMock).getLastHostId();

Check warning on line 184 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bR&open=AaHSLmEtussJYe4A13bR&pullRequest=14484
}

@Test
public void getEndPointForBitmapRemovalTestClvmVolumeOfStoppedVmRoutesToLockHolderInsteadOfLastHost() {
mockClvmVolumeOfStoppedVm(DEST_HOST_ID);
Mockito.doReturn(endPointMock).when(defaultEndPointSelectorSpy).getEndPointFromHostId(DEST_HOST_ID);

Check warning on line 190 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bS&open=AaHSLmEtussJYe4A13bS&pullRequest=14484

EndPoint result = defaultEndPointSelectorSpy.getEndPointForBitmapRemoval(snapshotInfoMock, false);

assertEquals(endPointMock, result);
Mockito.verify(defaultEndPointSelectorSpy, Mockito.never()).getEndPointFromHostId(HOST_ID);

Check warning on line 195 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "verify".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bT&open=AaHSLmEtussJYe4A13bT&pullRequest=14484

Check warning on line 195 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "never".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bU&open=AaHSLmEtussJYe4A13bU&pullRequest=14484
}

@Test
public void getEndPointForBitmapRemovalTestClvmVolumeOfStoppedVmWithoutLockHolderFallsBackToLastHost() {
mockClvmVolumeOfStoppedVm(null);
Mockito.doReturn(endPointMock).when(defaultEndPointSelectorSpy).getEndPointFromHostId(HOST_ID);

Check warning on line 201 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bV&open=AaHSLmEtussJYe4A13bV&pullRequest=14484

EndPoint result = defaultEndPointSelectorSpy.getEndPointForBitmapRemoval(snapshotInfoMock, false);

assertEquals(endPointMock, result);
}

@Test
public void getEndPointForBitmapRemovalTestClvmVolumeOfRunningVmUsesVmHostWithoutLockLookup() {
Mockito.doReturn(true).when(volumeInfoMock).isAttachedVM();

Check warning on line 210 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bW&open=AaHSLmEtussJYe4A13bW&pullRequest=14484
Mockito.doReturn(virtualMachineMock).when(volumeInfoMock).getAttachedVM();

Check warning on line 211 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bX&open=AaHSLmEtussJYe4A13bX&pullRequest=14484
Mockito.doReturn(HOST_ID).when(virtualMachineMock).getHostId();

Check warning on line 212 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bY&open=AaHSLmEtussJYe4A13bY&pullRequest=14484
Mockito.doReturn(endPointMock).when(defaultEndPointSelectorSpy).getEndPointFromHostId(HOST_ID);

Check warning on line 213 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "doReturn".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bZ&open=AaHSLmEtussJYe4A13bZ&pullRequest=14484

EndPoint result = defaultEndPointSelectorSpy.getEndPointForBitmapRemoval(snapshotInfoMock, false);

assertEquals(endPointMock, result);
Mockito.verify(defaultEndPointSelectorSpy, Mockito.never()).getClvmLockHostId(volumeInfoMock);

Check warning on line 218 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "verify".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13ba&open=AaHSLmEtussJYe4A13ba&pullRequest=14484

Check warning on line 218 in engine/storage/src/test/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "never".

See more on https://sonarcloud.io/project/issues?id=apache_cloudstack&issues=AaHSLmEtussJYe4A13bb&open=AaHSLmEtussJYe4A13bb&pullRequest=14484
}

@Test
public void getEndPointForSnapshotOperationsInKvmTestVolumeIsNotAttachedToVMAndSnapshotOnPrimary() {
Mockito.doReturn(null).when(volumeInfoMock).getAttachedVM();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,15 @@ public Answer createSnapshot(final CreateObjectCommand cmd) {
String diskPath = disk.getPath();
String snapshotPath = diskPath + File.separator + snapshotName;
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
if (DomainInfo.DomainState.VIR_DOMAIN_RUNNING.equals(state) && !primaryPool.isExternalSnapshot()) {
boolean isClvmNgIncremental = primaryPool.getType() == StoragePoolType.CLVM_NG && snapshotTO.isKvmIncrementalSnapshot();
if (isClvmNgIncremental && secondaryPool == null) {
String errorMsg = String.format("Incremental snapshots for CLVM_NG require secondary storage. " +
"Please configure secondary storage or disable incremental snapshots for volume [%s].", volume.getName());
logger.error(errorMsg);
return new CreateObjectAnswer(errorMsg);
}
boolean isLiveClvmNgIncremental = isClvmNgIncremental && (DomainInfo.DomainState.VIR_DOMAIN_RUNNING.equals(state) || DomainInfo.DomainState.VIR_DOMAIN_PAUSED.equals(state));
if ((DomainInfo.DomainState.VIR_DOMAIN_RUNNING.equals(state) && !primaryPool.isExternalSnapshot()) || isLiveClvmNgIncremental) {
if (snapshotTO.isKvmIncrementalSnapshot()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required.

newSnapshot = takeIncrementalVolumeSnapshotOfRunningVm(snapshotTO, primaryPool, secondaryPool, imageStoreTo != null ? imageStoreTo.getUrl() : null, snapshotName, volume, vm, conn, cmd.getWait());
} else {
Expand All @@ -2111,13 +2119,7 @@ public Answer createSnapshot(final CreateObjectCommand cmd) {
newSnapshot.setPhysicalSize(snapshotSize);
}
} else if (primaryPool.getType() == StoragePoolType.CLVM || primaryPool.getType() == StoragePoolType.CLVM_NG) {
if (primaryPool.getType() == StoragePoolType.CLVM_NG && snapshotTO.isKvmIncrementalSnapshot()) {
if (secondaryPool == null) {
String errorMsg = String.format("Incremental snapshots for CLVM_NG require secondary storage. " +
"Please configure secondary storage or disable incremental snapshots for volume [%s].", volume.getName());
logger.error(errorMsg);
return new CreateObjectAnswer(errorMsg);
}
if (isClvmNgIncremental) {
logger.info("Taking incremental snapshot of CLVM_NG volume [{}] using QCOW2 backup to secondary storage.", volume.getName());
newSnapshot = takeIncrementalVolumeSnapshotOfStoppedVm(snapshotTO, primaryPool, secondaryPool,
imageStoreTo.getUrl(), snapshotName, volume, conn, cmd.getWait());
Comment on lines +2122 to 2125

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a false positive - there's a guard before. So no NPE.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1649,16 +1649,17 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
boolean backupSnapToSecondary = isBackupSnapshotToSecondaryForZone(volume.getDataCenterId());

StoragePoolType poolType = volume.getStoragePoolType();
boolean isClvmNgIncrementalCandidate = StoragePoolType.CLVM_NG == poolType && backupSnapToSecondary && kvmIncrementalSnapshot.valueIn(clusterId);

updateSnapshotPayload(volume.getPoolId(), payload, isKvmAndFileBasedStorage, poolType, clusterId);
updateSnapshotPayload(volume.getPoolId(), payload, isKvmAndFileBasedStorage, isClvmNgIncrementalCandidate, clusterId);

// NetApp ONTAP managed PRIMARY snapshots remain on primary/array storage (FlexVol).
// They must not use secondary archive bookkeeping (postSnapshotDirectlyToSecondary) or a physical
// secondary copy — delete is handled via StorageSystemSnapshotStrategy → driver deleteAsync.
boolean archiveSnapshotToSecondary = backupSnapToSecondary
&& !isOntapManagedPrimaryLocationSnapshot(storagePool, payload);

if (isKvmAndFileBasedStorage && archiveSnapshotToSecondary) {
if ((isKvmAndFileBasedStorage || isClvmNgIncrementalCandidate) && archiveSnapshotToSecondary) {
DataStore imageStore = snapshotSrv.findSnapshotImageStore(snapshot);
if (imageStore == null) {
throw new CloudRuntimeException(String.format("Could not find any secondary storage to allocate snapshot [%s].", snapshot));
Expand All @@ -1681,7 +1682,7 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
SnapshotInfo snapshotOnPrimary = snapshotStrategy.takeSnapshot(snapshot);

if (archiveSnapshotToSecondary) {
if (!isKvmAndFileBasedStorage) {
if (!isKvmAndFileBasedStorage && !isClvmNgIncrementalCandidate) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed.

backupSnapshotToSecondary(payload.getAsyncBackup(), snapshotStrategy, snapshotOnPrimary, payload.getZoneIds(), payload.getStoragePoolIds());
Comment on lines +1685 to 1686

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following the same as file based kvm path

if (!payload.getAsyncBackup() && ClvmPoolManager.isClvmPoolType(storagePool.getPoolType())) {
_snapshotStoreDao.removeBySnapshotStore(snapshotId, snapshotOnPrimary.getDataStore().getId(), snapshotOnPrimary.getDataStore().getRole());
Expand Down Expand Up @@ -1714,7 +1715,7 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
snapshotZoneDao.addSnapshotToZone(snapshotId, snapshot.getDataCenterId());

DataStoreRole dataStoreRole;
if (payload.getAsyncBackup() && archiveSnapshotToSecondary && !isKvmAndFileBasedStorage) {
if (payload.getAsyncBackup() && archiveSnapshotToSecondary && !isKvmAndFileBasedStorage && !isClvmNgIncrementalCandidate) {
dataStoreRole = DataStoreRole.Primary;
} else {
dataStoreRole = archiveSnapshotToSecondary ? snapshotHelper.getDataStoreRole(snapshot) : DataStoreRole.Primary;
Expand Down Expand Up @@ -1913,7 +1914,7 @@ void removeClvmPrimarySnapshotStoreRefIfNeeded(SnapshotInfo snapshotOnPrimary) {
}
}

private void updateSnapshotPayload(long storagePoolId, CreateSnapshotPayload payload, boolean isKvmAndFileBasedStorage, StoragePoolType poolType, Long clusterId) {
private void updateSnapshotPayload(long storagePoolId, CreateSnapshotPayload payload, boolean isKvmAndFileBasedStorage, boolean isClvmNgIncrementalCandidate, Long clusterId) {
StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePoolId);

if (storagePoolVO.isManaged()) {
Expand All @@ -1926,7 +1927,7 @@ private void updateSnapshotPayload(long storagePoolId, CreateSnapshotPayload pay
payload.setLocationType(null);
}

if (isKvmAndFileBasedStorage && kvmIncrementalSnapshot.valueIn(clusterId)) {
if ((isKvmAndFileBasedStorage && kvmIncrementalSnapshot.valueIn(clusterId)) || isClvmNgIncrementalCandidate) {
payload.setKvmIncrementalSnapshot(true);
}
}
Expand Down
Loading