Repository navigation
Add support for clvm-ng incremental volume snaps #14484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
77f48dd
2f1249b
dde3d73
3aa5dc3
d16e1aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()) { | ||
| newSnapshot = takeIncrementalVolumeSnapshotOfRunningVm(snapshotTO, primaryPool, secondaryPool, imageStoreTo != null ? imageStoreTo.getUrl() : null, snapshotName, volume, vm, conn, cmd.getWait()); | ||
| } else { | ||
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)); | ||
|
|
@@ -1681,7 +1682,7 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc | |
| SnapshotInfo snapshotOnPrimary = snapshotStrategy.takeSnapshot(snapshot); | ||
|
|
||
| if (archiveSnapshotToSecondary) { | ||
| if (!isKvmAndFileBasedStorage) { | ||
| if (!isKvmAndFileBasedStorage && !isClvmNgIncrementalCandidate) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
|
|
@@ -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; | ||
|
|
@@ -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()) { | ||
|
|
@@ -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); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required.