Skip to content

Commit 8714092

Browse files
committed
Addressed reviews
1 parent 3c792aa commit 8714092

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/snapshot/StorPoolSnapshotStrategy.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ public boolean deleteSnapshot(Long snapshotId, Long zoneId) {
115115
if (resp.getError() != null) {
116116
final String err = String.format("Failed to clean-up Storpool snapshot %s. Error: %s", name, resp.getError());
117117
StorPoolUtil.spLog(err);
118-
markSnapshotAsDestroyedIfAlreadyRemoved(snapshotId, resp, resp.getError().getName().equals("objectDoesNotExist"));
118+
markSnapshotAsDestroyedIfAlreadyRemoved(snapshotId, resp.getError().getName().equals("objectDoesNotExist"));
119119
throw new CloudRuntimeException(err);
120120
} else {
121121
res = deleteSnapshotFromDbIfNeeded(snapshotVO, zoneId);
122-
markSnapshotAsDestroyedIfAlreadyRemoved(snapshotId, resp, true);
122+
markSnapshotAsDestroyedIfAlreadyRemoved(snapshotId,true);
123123
StorPoolUtil.spLog("StorpoolSnapshotStrategy.deleteSnapshot: executed successfully=%s, snapshot uuid=%s, name=%s", res, snapshotVO.getUuid(), name);
124124
}
125125
} catch (Exception e) {
@@ -136,14 +136,15 @@ public boolean deleteSnapshot(Long snapshotId, Long zoneId) {
136136
return res;
137137
}
138138

139-
private void markSnapshotAsDestroyedIfAlreadyRemoved(Long snapshotId, SpApiResponse resp, boolean isSnapshotDeleted) {
140-
if (isSnapshotDeleted) {
141-
List<SnapshotDataStoreVO> snapshotsOnStore = _snapshotStoreDao.listBySnapshotIdAndState(snapshotId, State.Ready);
142-
for (SnapshotDataStoreVO snapshot : snapshotsOnStore) {
143-
if (snapshot.getInstallPath() != null && snapshot.getInstallPath().contains(StorPoolUtil.SP_DEV_PATH)) {
144-
snapshot.setState(State.Destroyed);
145-
_snapshotStoreDao.update(snapshot.getId(), snapshot);
146-
}
139+
private void markSnapshotAsDestroyedIfAlreadyRemoved(Long snapshotId, boolean isSnapshotDeleted) {
140+
if (!isSnapshotDeleted) {
141+
return;
142+
}
143+
List<SnapshotDataStoreVO> snapshotsOnStore = _snapshotStoreDao.listBySnapshotIdAndState(snapshotId, State.Ready);
144+
for (SnapshotDataStoreVO snapshot : snapshotsOnStore) {
145+
if (snapshot.getInstallPath() != null && snapshot.getInstallPath().contains(StorPoolUtil.SP_DEV_PATH)) {
146+
snapshot.setState(State.Destroyed);
147+
_snapshotStoreDao.update(snapshot.getId(), snapshot);
147148
}
148149
}
149150
}

0 commit comments

Comments
 (0)