-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-15488. Add a command to list all snapshots for a snaphottable root with snapshot Ids. #2166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanx @bshashikant for the work here. Had a very quick look, so might have missed stuffs(spare me for that, if so :-) ) mostly looks good.
Couple of stuffs give a check, Jenkins too has some complains, that you need to sort as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should relative path be resolved as well?
Path absF = fixRelativePart(path); - Should Increment Read Statistics as well.
statistics.incrementReadOps(1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be :
ClientProtocol#getSnapshotListing(String)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems Copy-paste error, Change to
try (TraceScope ignored = tracer.newScope("getSnapshotListing")) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the argument name consistent, In ClientProtocol & Router its snapshotRoot, better keep same everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should put the path as well in the audit log too
logAuditEvent(success, "listSnapshots", snapshotRoot);
...hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/snapshot/LsSnapshot.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead can use
DistributedFileSystem dfs = AdminHelper.getDFS(getConf());
This shall handle ViewFsOverloadScheme as well.
This would throw IllegalArgumentException so it should be inside the try block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to print the stack trace on the CLI? Just a line of error should work? Mostly it should trigger for FNF or for SnapshotException if the directory is not snapshottable. if required we can have the exception with trace in the debug log
Apart we should catch Exception as well for any runtime exceptions, propagating the exception in CLI won't look good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fsn is already there, can change to:
fsn.getSnapshotManager().setAllowNestedSnapshots(true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use LambdaTestUtils :
``LambdaTestUtils.intercept(SnapshotException.class,
"Directory is not a " + "snapshottable directory",
() -> hdfs.getSnapshotListing(dir1)); ``
|
@bshashikant can you please paste the command output in the PR pelase ? |
...project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotStatus.java
Outdated
Show resolved
Hide resolved
|
Thanks @ayushtkn and @mukul1987 for the review comments. The latest patch addresses the review comments. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
| if (rpcServer.isInvokeConcurrent(snapshotRoot)) { | ||
| Map<RemoteLocation, SnapshotStatus[]> ret = rpcClient.invokeConcurrent( | ||
| locations, remoteMethod, true, false, SnapshotStatus[].class); | ||
| return ret.values().iterator().next(); | ||
| } else { | ||
| return rpcClient.invokeSequential( | ||
| locations, remoteMethod, SnapshotStatus[].class, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the SnapshotStatus contains parentpath as well, the path will be the one wrt the actual namespace not with respect to mount table. You need to replace the parentpath with path corresponding to the mount entry.
if mount entry is : /mnt -> /dir in ns0, then if you trigger call on ns0 the path would be something like /dir/sub.. that you need to change to /mnt/sub..
In case of InvokeConcurrent you would be able to get Src and Dst from the ret and maybe something like this may work -
response = ret.values().iterator().next();
String src = ret.keySet().iterator().next().getSrc();
String dst = ret.keySet().iterator().next().getDest();
for (SnapshotStatus s : response) {
String mountPath =
new String(s.getParentFullPath()).replaceFirst(dst, src);
s.setParentFullPath(mountPath.getBytes());
}
For the invokeSequential one you won't be having the detail on which location did the call got success, For that you have to get it returned back from RouterRpcClient#L858, I guess to get the location returned you would require a new InvokeSequential method which returns the location as well, may be can refactor and reuse this one...
This problem would be there I think in getSnapshottableDirListing() as well. If you want, you can put a TODO and handle the location stuff in a separate follow up jira for both API's.
...p-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterSnapshot.java
Show resolved
Hide resolved
|
💔 -1 overall
This message was automatically generated. |
...op-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
Outdated
Show resolved
Hide resolved
...doop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java
Show resolved
Hide resolved
...oop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestListSnapshot.java
Outdated
Show resolved
Hide resolved
...oop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestListSnapshot.java
Show resolved
Hide resolved
...oop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestListSnapshot.java
Outdated
Show resolved
Hide resolved
|
Thanks for updating the patch @bshashikant. I am generally +1 for the patch. Some nit picks, minor comments. |
|
|
||
| // Fields specific for snapshot directory | ||
| required uint32 snapshotID = 2; | ||
| required bytes parent_fullpath = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also dispay if a particular snapshot is deleted/garbage collected or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the intent was to hide the information from the user whether a snapshot is deleted or not. This is a user cmd and displaying it won't server the purpose if we are supposed to hide it.
|
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the patch @bshashikant. +1 the patch looks good to me.
|
Give a check to test failures. |
|
💔 -1 overall
This message was automatically generated. |
Addressed in the latest patch. |
|
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanx @bshashikant for the update,
Apart from checkstyle issues, Changes LGTM +1
|
Committed this one leaving few of the checkstyke issues ignored as similar issues still exist in other test classes. |
|
Thanks @ayushtkn and @mukul1987 for the review. |
|
💔 -1 overall
This message was automatically generated. |
please see https://issues.apache.org/jira/browse/HDFS-15488
COMMAND OUTPUT
sbanerjee-MBP15:hadoop-3.4.0-SNAPSHOT sbanerjee$ bin/hdfs lsSnapshottableDir
drwxr-xr-x 0 sbanerjee supergroup 0 2020-07-27 11:52 2 65536 /user
sbanerjee-MBP15:hadoop-3.4.0-SNAPSHOT sbanerjee$ bin/hdfs lsSnapshot /user
drwxr-xr-x 0 sbanerjee supergroup 0 2020-07-27 11:52 1 /user/.snapshot/s1
drwxr-xr-x 0 sbanerjee supergroup 0 2020-07-27 11:51 0 /user/.snapshot/s20200727-115156.407