You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2023/01/16 06:57:09 UTC

[GitHub] [ozone] sadanand48 commented on a diff in pull request #4015: HDDS-6984. [Snapshot] Prevent bucket from being deleted if snapshot exists

sadanand48 commented on code in PR #4015:
URL: https://github.com/apache/ozone/pull/4015#discussion_r1070890956


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -198,6 +216,42 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
     }
   }
 
+  private boolean bucketContainsSnapshot(OMMetadataManager omMetadataManager,
+      String snapshotBucketKey) throws IOException {
+    return bucketContainsSnapshotInCache(omMetadataManager, snapshotBucketKey)
+        || bucketContainsSnapshotInTable(omMetadataManager, snapshotBucketKey);
+  }
+
+  private boolean bucketContainsSnapshotInTable(
+      OMMetadataManager omMetadataManager, String snapshotBucketKey)
+      throws IOException {
+    try (
+        TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
+            snapshotIterator = omMetadataManager
+            .getSnapshotInfoTable().iterator()) {
+      snapshotIterator.seek(snapshotBucketKey);
+      if (snapshotIterator.hasNext()) {
+        return snapshotIterator.next().getKey().startsWith(snapshotBucketKey);

Review Comment:
   Added a TODO on line 248.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org