This is an automated email from the ASF dual-hosted git repository.
devesh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 0ce031d985 HDDS-9644. Fixed incorrect validation of path with
namespace du commands. (#6755)
0ce031d985 is described below
commit 0ce031d9859133b32dd0ea7e1900392d853860d2
Author: SaketaChalamchala <[email protected]>
AuthorDate: Mon Jun 17 21:20:23 2024 -0700
HDDS-9644. Fixed incorrect validation of path with namespace du commands.
(#6755)
Thanks @SaketaChalamchala for improving the patch. Thanks @ArafatKhan2198
for review.
---
.../hadoop/ozone/shell/TestNSSummaryAdmin.java | 20 ++++++++++++++++++--
.../ozone/admin/nssummary/DiskUsageSubCommand.java | 4 ----
.../hadoop/ozone/admin/nssummary/NSSummaryAdmin.java | 6 ++++++
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
index c9e6e13806..fdc3ec0008 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
@@ -114,8 +114,24 @@ public class TestNSSummaryAdmin extends
StandardOutputTestBase {
// Running on root path.
String path = "/";
executeAdminCommands(path);
- // Should throw warning - only buckets can have bucket layout.
- assertThat(getOutContentString()).contains("[Warning] Namespace CLI is not
designed for OBS bucket layout.");
+ assertThat(getOutContentString()).doesNotContain("INVALID_VOLUME_NAME");
+ assertThat(getOutContentString()).doesNotContain(
+ "[Warning] Namespace CLI is not designed for OBS bucket layout.");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize DU");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize file size distribution");
+ }
+
+ /**
+ * Test NSSummaryCLI on volume.
+ */
+ @Test
+ public void testNSSummaryCLIVolume() throws UnsupportedEncodingException {
+ // Running on /volume path.
+ String path = "/" + volumeName;
+ executeAdminCommands(path);
+ assertThat(getOutContentString()).doesNotContain("INVALID_BUCKET_NAME");
+ assertThat(getOutContentString()).doesNotContain(
+ "[Warning] Namespace CLI is not designed for OBS bucket layout.");
assertThat(getOutContentString()).contains("Put more files into it to
visualize DU");
assertThat(getOutContentString()).contains("Put more files into it to
visualize file size distribution");
}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/DiskUsageSubCommand.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/DiskUsageSubCommand.java
index 3e7214ce98..6f29ea40fc 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/DiskUsageSubCommand.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/DiskUsageSubCommand.java
@@ -30,7 +30,6 @@ import static
org.apache.hadoop.ozone.OzoneConsts.OM_KEY_PREFIX;
import static
org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.makeHttpCall;
import static
org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.parseInputPath;
import static
org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printEmptyPathRequest;
-import static
org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printBucketReminder;
import static
org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printKVSeparator;
import static
org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printNewLines;
import static
org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printPathNotFound;
@@ -104,9 +103,6 @@ public class DiskUsageSubCommand implements Callable {
if ("PATH_NOT_FOUND".equals(duResponse.path("status").asText(""))) {
printPathNotFound();
} else {
- if (parent.isNotValidBucketOrOBSBucket(path)) {
- printBucketReminder();
- }
long totalSize = duResponse.path("size").asLong(-1);
if (!noHeader) {
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
index 0521e8fd74..991099f270 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
@@ -115,6 +115,12 @@ public class NSSummaryAdmin extends GenericCli implements
SubcommandWithParent {
OzoneConfiguration.of(getOzoneConfig()));
try (OzoneClient ozoneClient =
OzoneClientFactory.getRpcClient(getOzoneConfig())) {
ObjectStore objectStore = ozoneClient.getObjectStore();
+ // Return false if path is root "/" or
+ // contains just the volume and no bucket like "/volume"
+ if (ofsPath.getVolumeName().isEmpty() ||
+ ofsPath.getBucketName().isEmpty()) {
+ return false;
+ }
// Checks if the bucket is part of the path.
OzoneBucket bucket = objectStore.getVolume(ofsPath.getVolumeName())
.getBucket(ofsPath.getBucketName());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]