-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-14856. Fetch file ACLs while mounting external store. #1478
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
@@ -379,6 +379,8 @@ | |||
public static final String DFS_PROVIDED_ALIASMAP_TEXT_WRITE_DIR_DEFAULT = "file:///tmp/"; | |||
|
|||
public static final String DFS_PROVIDED_ALIASMAP_LEVELDB_PATH = "dfs.provided.aliasmap.leveldb.path"; | |||
public static final String DFS_NAMENODE_MOUNT_ACLS_ENABLED = "dfs.namenode.mount.acls.enabled"; |
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 we refer to PROVIDED here?
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.
Agree. WDYT about dfs.namenode.provided.acls.enabled
?
Keep namenode
since the config is a NN config.
Replaced mount
with provided
so that the config name is consistent.
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.
Better than before for sure.
Not sure about the end policy for distinguishing namenode from not.
It should be consistent.
@@ -55,7 +79,7 @@ public FSTreeWalk(Path root, Configuration conf) throws IOException { | |||
try { | |||
ArrayList<TreePath> ret = new ArrayList<>(); | |||
for (FileStatus s : fs.listStatus(path.getFileStatus().getPath())) { | |||
ret.add(new TreePath(s, id, i, fs)); | |||
ret.add(new TreePath(s, id, i, fs, getAclStatus(fs, s.getPath()))); |
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.
Extract for readability.
getPendingQueue().addFirst( | ||
new TreePath(p.getFileStatus(), p.getParentId(), this, fs)); | ||
new TreePath(p.getFileStatus(), p.getParentId(), this, fs, acls)); |
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.
Extract.
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.
Do we support adding null to the acls?
Is there a finer grain exception then IOException?
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.
ACL can be null
.
IOException
comes from the FileSystems
API, AclStatus getAclStatus(Path path) throws IOException
} | ||
|
||
FSTreeIterator(Path p) throws IOException { | ||
try { | ||
FileStatus s = fs.getFileStatus(root); | ||
getPendingQueue().addFirst(new TreePath(s, -1L, this, fs)); | ||
AclStatus acls = getAclStatus(fs, s.getPath()); |
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.
This one we don't care about the IOE?
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.
Good catch. The scanner will not fail if the remote FS does not support ACLs. All other IOException fail the operation in all paths now. Thanks !
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.
@ashvina - is it possible to handle the exception the same way in both the constructors?
@@ -105,5 +150,4 @@ public TreeIterator iterator() { | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
|
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.
Avoid
.setPermission(permissions); | ||
if (aclStatus != null) { | ||
throw new UnsupportedOperationException( | ||
"Acls not supported by ImageWriter"); |
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.
ACLs
@@ -17,6 +17,8 @@ | |||
*/ | |||
package org.apache.hadoop.hdfs.server.namenode; | |||
|
|||
import org.apache.hadoop.fs.Path; |
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.
Needed?
* @param aclStatus AclStatus on external store. | ||
* @return locally mapped user name. | ||
*/ | ||
public String user(AclStatus aclStatus) { |
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.
getUser()
Is this static?
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.
Why do we have this just for doing a get?
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.
The user mapping behavior can be different in a subclass. For e.g. In this case SingleUGIResolver
maps all users to a single user.
* @param aclStatus remote ACL status. | ||
* @return local HDFS ACL entries. | ||
*/ | ||
public List<AclEntry> aclEntries(AclStatus aclStatus) { |
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.
static getACLEntries()
addGroup(remoteAcl.getGroup()); | ||
for (AclEntry entry : remoteAcl.getEntries()) { | ||
// add the users and groups in this acl entry to ugi | ||
if (entry.getName() != 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.
Extract getName()
🎊 +1 overall
This message was automatically generated. |
.setPermission(ugi.resolve(s)); | ||
.setPermission(permissions); | ||
if (aclStatus != null) { | ||
throw new UnsupportedOperationException( |
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.
So, this is not currently written to the image?
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.
Yes. I am proposing to fix the scanner in the PR which is independent of the ImageWriter
. The consumer of the scanner can choose to ignore the ACL.
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 you make this explicit (e.g,, add javadoc for this method)?
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
} | ||
|
||
FSTreeIterator(Path p) throws IOException { | ||
try { | ||
FileStatus s = fs.getFileStatus(root); | ||
getPendingQueue().addFirst(new TreePath(s, -1L, this, fs)); | ||
AclStatus acls = getAclStatus(fs, s.getPath()); |
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.
@ashvina - is it possible to handle the exception the same way in both the constructors?
...op-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/UGIResolver.java
Show resolved
Hide resolved
* Validate FSTreeWalk specific behavior | ||
*/ | ||
public class TestFSTreeWalk { | ||
// verify that the ACLs are fetched when configured |
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.
change to javadoc style comment.
try { | ||
return fs.getAclStatus(path); | ||
} catch (UnsupportedOperationException e) { | ||
LOG.warn("Remote filesystem {} doesn't support ACLs", fs); |
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 we have a unit test checking for this string?
.setPermission(ugi.resolve(s)); | ||
.setPermission(permissions); | ||
if (aclStatus != null) { | ||
throw new UnsupportedOperationException("ACLs not supported by ImageWriter"); |
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.
Too long.
@@ -132,4 +135,57 @@ public FsPermission permission(FileStatus s) { | |||
return s.getPermission(); | |||
} | |||
|
|||
private long resolve(AclStatus aclStatus) { |
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.
static?
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.
No. Static will not work as resolution methods in the subclass may not be static.
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -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.
+1 once the comments are resolved and yetus issues (mostly checkstyle; failed tests seem unrelated) are resolved.
💔 -1 overall
This message was automatically generated. |
d2434b7
to
73140e1
Compare
💔 -1 overall
This message was automatically generated. |
...tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSTreeWalk.java
Show resolved
Hide resolved
...tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSTreeWalk.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.
@ashvina Sorry about the delay on this. I have a couple of minor comments. I am +1 on this once these are fixed.
...tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSTreeWalk.java
Show resolved
Hide resolved
...tools/hadoop-fs2img/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSTreeWalk.java
Show resolved
Hide resolved
d2c8ba4
to
1bd5ee0
Compare
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Test failures are unrelated. Completing this PR. |
Addresses https://issues.apache.org/jira/browse/HDFS-14856.
If configuration
dfs.namenode.mount.acls.enabled
is set (true),FsTreeWalk
will fetch ACLs of files on the external storage system provided at the time of mount.