slavkap commented on code in PR #9270:
URL: https://github.com/apache/cloudstack/pull/9270#discussion_r1740704043
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -394,11 +403,35 @@ public Snapshot revertSnapshot(Long snapshotId) {
_resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(),
ResourceType.primary_storage, new Long(volume.getSize() - snapshot.getSize()));
volume.setSize(snapshot.getSize());
_volsDao.update(volume.getId(), volume);
+ endSnapshotChainForVolume(snapshot.getVolumeId(),
snapshot.getHypervisorType());
return snapshotInfo;
}
return null;
}
+ /**
+ * Marks the snapshot chain as finished if the volume is on KVM.
+ * */
+ @Override
+ public void endSnapshotChainForVolume(long volumeId, HypervisorType
hypervisorType) {
+ if (!HypervisorType.KVM.equals(hypervisorType)) {
+ return;
+ }
+
+ SnapshotDataStoreVO snapshotOnPrimary =
_snapshotStoreDao.findLatestSnapshotForVolume(volumeId, DataStoreRole.Primary);
+ SnapshotDataStoreVO snapshotOnSecondary =
_snapshotStoreDao.findLatestSnapshotForVolume(volumeId, DataStoreRole.Image);
+
+ if (snapshotOnPrimary != null) {
+ snapshotOnPrimary.setEndOfChain(true);
+ _snapshotStoreDao.update(snapshotOnPrimary.getId(),
snapshotOnPrimary);
+ }
+
+ if (snapshotOnSecondary != null) {
+ snapshotOnSecondary.setEndOfChain(true);
Review Comment:
when there is a copy in another zone it will set the end of chain on the copy
```
| id | store_id | snapshot_id | created | last_updated
| job_id | store_role | size |
physical_size | parent_snapshot_id | install_path
| state | update_count | ref_cnt | updated | volume_id |
download_state | download_pct | error_str
| display | local_path
| kvm_checkpoint_path
| end_of_chain |
download_url | download_url_created |
+------+----------+-------------+---------------------+---------------------+--------------------------------------+------------+-------------+---------------+--------------------+-------------------------------------------------------+-------+--------------+---------+---------------------+-----------+----------------+--------------+---------------------------------------------------+---------+----------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------------+--------------+----------------------+
| 4357 | 6 | 1968 | 2024-09-02 08:27:44 | NULL
| NULL | Image | 21474836480 |
2188509184 | 1966 |
snapshots/2/1078/c0f52efb-e71c-4dec-bbdf-9ccc565c64c3 | Ready | 0 |
0 | NULL | 1078 | NULL | 0 | NULL
| 1 | NULL
|
/mnt/dc75bca1-2951-366c-88a2-bb4c840b0148/checkpoints/2/1078/c0f52efb-e71c-4dec-bbdf-9ccc565c64c3
| NULL | NULL | NULL |
| 4358 | 5 | 1968 | 2024-09-02 08:28:44 | 2024-09-02 08:29:48
| 884901b2-ebab-4f77-a962-4ec9e07d0928 | Image | 0 |
2112880640 | 0 |
snapshots/2/1078/c0f52efb-e71c-4dec-bbdf-9ccc565c64c3 | Ready | 2 |
0 | 2024-09-02 08:29:49 | 1078 | DOWNLOADED | 100 |
Install completed successfully at 9/2/24, 8:29 AM | 1 |
/mnt/SecStorage/bc39016e-2b13-3fdc-ad86-4996fa18d364/snapshots/2/1078/dnld16700618417968862303tmp_
| NULL
| 1 | NULL | 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]