JoaoJandre commented on code in PR #9855:
URL: https://github.com/apache/cloudstack/pull/9855#discussion_r1816616222
##########
plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/snapshot/StorPoolSnapshotStrategy.java:
##########
@@ -129,15 +128,22 @@ public boolean deleteSnapshot(Long snapshotId, Long
zoneId) {
}
}
+ List<SnapshotDataStoreVO> snapshots =
_snapshotStoreDao.listBySnapshotIdAndState(snapshotId, State.Ready);
+ if (res || CollectionUtils.isEmpty(snapshots)) {
+ updateSnapshotToDestroyed(snapshotVO);
+ return true;
+ }
return res;
}
- private void markSnapshotAsDestroyedIfAlreadyRemoved(Long snapshotId,
SpApiResponse resp) {
- if (resp.getError().getName().equals("objectDoesNotExist")) {
- SnapshotDataStoreVO snapshotOnPrimary =
_snapshotStoreDao.findBySourceSnapshot(snapshotId, DataStoreRole.Primary);
- if (snapshotOnPrimary != null) {
- snapshotOnPrimary.setState(State.Destroyed);
- _snapshotStoreDao.update(snapshotOnPrimary.getId(),
snapshotOnPrimary);
+ private void markSnapshotAsDestroyedIfAlreadyRemoved(Long snapshotId,
SpApiResponse resp, boolean isSnapshotDeleted) {
+ if (isSnapshotDeleted) {
+ List<SnapshotDataStoreVO> snapshotsOnStore =
_snapshotStoreDao.listBySnapshotIdAndState(snapshotId, State.Ready);
+ for (SnapshotDataStoreVO snapshot : snapshotsOnStore) {
+ if (snapshot.getInstallPath() != null &&
snapshot.getInstallPath().contains(StorPoolUtil.SP_DEV_PATH)) {
+ snapshot.setState(State.Destroyed);
+ _snapshotStoreDao.update(snapshot.getId(), snapshot);
+ }
}
Review Comment:
```suggestion
if (!isSnapshotDeleted) {
return;
}
List<SnapshotDataStoreVO> snapshotsOnStore =
_snapshotStoreDao.listBySnapshotIdAndState(snapshotId, State.Ready);
for (SnapshotDataStoreVO snapshot : snapshotsOnStore) {
if (snapshot.getInstallPath() != null &&
snapshot.getInstallPath().contains(StorPoolUtil.SP_DEV_PATH)) {
snapshot.setState(State.Destroyed);
_snapshotStoreDao.update(snapshot.getId(), snapshot);
}
```
--
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]