slavkap commented on code in PR #9478:
URL: https://github.com/apache/cloudstack/pull/9478#discussion_r1761276987
##########
plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/collector/StorPoolAbandonObjectsCollector.java:
##########
@@ -322,4 +340,72 @@ private Map<String,String>
getStorPoolNamesAndCsTag(JsonArray arr) {
}
return map;
}
+
+ class StorPoolSnapshotRecoveryCheck extends ManagedContextRunnable {
+
+ @Override
+ protected void runInContext() {
+ List<StoragePoolVO> spPools =
storagePoolDao.findPoolsByProvider(StorPoolUtil.SP_PROVIDER_NAME);
+ if (CollectionUtils.isEmpty(spPools)) {
+ return;
+ }
+ List<SnapshotDetailsVO> snapshotDetails =
snapshotDetailsDao.findDetails(StorPoolUtil.SP_RECOVERED_SNAPSHOT);
+ if (CollectionUtils.isEmpty(snapshotDetails)) {
+ return;
+ }
+ Map<Long, StoragePoolVO> onePoolforZone = new HashMap<>();
+ for (StoragePoolVO storagePoolVO : spPools) {
+ onePoolforZone.put(storagePoolVO.getDataCenterId(),
storagePoolVO);
+ }
+ List<Long> recoveredSnapshots = new ArrayList<>();
+ for (StoragePoolVO storagePool : onePoolforZone.values()) {
+ try {
+ logger.debug(String.format("Checking StorPool recovered
snapshots for zone [%s]",
+ storagePool.getDataCenterId()));
+ SpConnectionDesc conn =
StorPoolUtil.getSpConnection(storagePool.getUuid(),
+ storagePool.getId(), storagePoolDetailsDao,
storagePoolDao);
+ JsonArray arr = StorPoolUtil.snapshotsList(conn);
+ List<String> snapshots = snapshotsForRcovery(arr);
+ if (snapshots.isEmpty()) {
+ continue;
+ }
+ for (SnapshotDetailsVO snapshot : snapshotDetails) {
+ String name = snapshot.getValue().split(";")[0];
+ String location = snapshot.getValue().split(";")[1];
+ if (name == null || location == null) {
+ StorPoolUtil.spLog("Could not find name or
location for the snapshot %s", snapshot.getValue());
+ continue;
+ }
+ if (snapshots.contains(name)) {
+ Long clusterId =
StorPoolHelper.findClusterIdByGlobalId(StorPoolUtil.getSnapshotClusterId(name,
conn), clusterDao);
+ conn = StorPoolHelper.getSpConnectionDesc(conn,
clusterId);
+ SpApiResponse resp =
StorPoolUtil.snapshotUnexport(name, location, conn);
+ if (resp.getError() == null) {
+ StorPoolUtil.spLog("Unexport of snapshot %s
was successful", name);
+ recoveredSnapshots.add(snapshot.getId());
+ } else {
+ StorPoolUtil.spLog("Could not recover StorPool
snapshot %s", resp.getError());
+ }
+ }
+ }
+ } catch (Exception e) {
+ logger.debug(String.format("Could not collect StorPool
recovered snapshots %s", e.getMessage()));
+ }
+ }
+ for (Long recoveredSnapshot : recoveredSnapshots) {
+ snapshotDetailsDao.remove(recoveredSnapshot);
+ }
+ }
+ }
+
+ private static List<String> snapshotsForRcovery(JsonArray arr) {
Review Comment:
thanks, it's fixed in the latest commits
--
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]