Skip to content

Commit

Permalink
HDDS-10562. Fix infinite loop in ozone fs -ls /volume (apache#6416)
Browse files Browse the repository at this point in the history
  • Loading branch information
symious authored Mar 24, 2024
1 parent f9e5178 commit 4ca8edb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -76,6 +77,7 @@
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
import static org.apache.hadoop.fs.FileSystem.FS_DEFAULT_NAME_KEY;
import static org.apache.hadoop.fs.FileSystem.TRASH_PREFIX;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_LISTING_PAGE_SIZE;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;

import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
Expand Down Expand Up @@ -753,6 +755,34 @@ public void testLinkBucketOrphan() throws Exception {
}
}

@Test
@Timeout(10)
public void testListBucket() throws Exception {
final String hostPrefix = OZONE_OFS_URI_SCHEME + "://" + omServiceId;
OzoneConfiguration clientConf =
getClientConfForOFS(hostPrefix, cluster.getConf());
int pageSize = 20;
clientConf.setInt(OZONE_FS_LISTING_PAGE_SIZE, pageSize);
URI uri = FileSystem.getDefaultUri(clientConf);
clientConf.setBoolean(String.format("fs.%s.impl.disable.cache", uri.getScheme()), true);
OzoneFsShell shell = new OzoneFsShell(clientConf);

String volName = "testlistbucket";
int numBuckets = pageSize;

try {
generateBuckets("/" + volName, numBuckets);
out.reset();
int res = ToolRunner.run(shell, new String[]{"-ls", "/" + volName});
assertEquals(0, res);
String r = out.toString(DEFAULT_ENCODING);
assertThat(r).matches("(?s)^Found " + numBuckets + " items.*");

} finally {
shell.close();
}
}

@Test
public void testDeleteTrashNoSkipTrash() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,9 @@ public List<FileStatusAdapter> listStatus(String pathStr, boolean recursive,
}
OFSPath ofsStartPath = new OFSPath(startPath, config);
if (ofsPath.isVolume()) {
String startBucket = ofsStartPath.getBucketName();
String startBucketPath = ofsStartPath.getNonKeyPath();
return listStatusVolume(ofsPath.getVolumeName(),
recursive, startBucket, numEntries, uri, workingDir, username);
recursive, startBucketPath, numEntries, uri, workingDir, username);
}

if (ofsPath.isSnapshotPath()) {
Expand Down

0 comments on commit 4ca8edb

Please sign in to comment.