-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-21995 Add a coprocessor to set HDFS ACL for hbase granted user #163
Conversation
💔 -1 overall
This message was automatically generated. |
hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
Outdated
Show resolved
Hide resolved
@@ -314,12 +316,24 @@ private FSDataInputStream tryOpen() throws IOException { | |||
return(in); | |||
} catch (FileNotFoundException e) { | |||
// Try another file location | |||
} catch (AccessControlException 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.
Here, I prefer to simplify the logic as a small method:
- remember the thrown exception as e;
- if notfound or accessControl exception, continue to try another file;
- if still not find an right file. then throw the e.
Please consider this.
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.
Please abstract all the exception handling logic as method named handleException ?
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.
done
for (int i = 0; i < locations.length; ++i) { | ||
try { | ||
return fs.getFileStatus(locations[i]); | ||
} catch (FileNotFoundException e) { | ||
// Try another file location | ||
} catch (AccessControlException 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.
Same question above.
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.
done
*/ | ||
@CoreCoprocessor | ||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG) | ||
public class HDFSAclController implements MasterCoprocessor, MasterObserver { |
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.
Not a good class name, the class want to sync file acl between HBase and HDFS ? and mostly for those directories when scanning snapshot ? we don't consider those directories which is unrelated to snapshot, such as WAL, oldWals etc... Please consider another name.
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.
How about "SnapshotScannerHDFSAclController"?
} | ||
|
||
@Override | ||
public void preMasterInitialization(final ObserverContext<MasterCoprocessorEnvironment> c) |
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 final can remove now in jdk8 ?
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.
done
masterServices = ((HasMasterServices) mEnv).getMasterServices(); | ||
} | ||
if (masterServices == null) { | ||
throw new RuntimeException("master services can not be 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.
IllegalArgumentException ?
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.
done
if (!fs.exists(path)) { | ||
fs.mkdirs(path); | ||
} | ||
fs.setPermission(path, ACL_ENABLE_PUBLIC_HFILE_PERMISSION); |
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 acl need also to be configurable ?
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.
done
ColumnFamilyDescriptorBuilder.newBuilder(HDFSAclStorage.HDFS_ACL_FAMILY).build()); | ||
admin.modifyTable(builder.build()); | ||
} | ||
} |
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.
What if the hbase:acl does not exist ? should throw an exception ?
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 coprocessor should be configured after the AccessController, if hbase:acl table does not exist, the AccessController will not work incorrectly firstly?
Let me add some logs and throw an TableNotFoundException here.
try (Admin admin = ctx.getEnvironment().getConnection().getAdmin()) { | ||
if (admin.tableExists(PermissionStorage.ACL_TABLE_NAME)) { | ||
// check if hbase:acl table has 'm' CF | ||
TableDescriptor tableDescriptor = admin.getDescriptor(PermissionStorage.ACL_TABLE_NAME); |
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.
Would the newly introduced CF impact the original AccessController ?
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 new CF is only used in this CP, it records if the hbase read permission is synchronized to related hfile.
This flag has two usages:
- check if we need to remove hdfs acls for a grant without READ permission;
- skip some hdfs acl sync because it may be already added.
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@mymeiyi Please check the failed UT. |
Any updates here? |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
To make hbase granted user have the access to scan table snapshots, use HDFS ACLs to set user 'access r-x' or 'default r-x' ACLs over hfiles.
The basic implementation is:
The feature is configurable because it's implemented in a master coprocessor.