-
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-22580 Add a table attribute to make user scan snapshot feature configurable for table #336
Conversation
💔 -1 overall
This message was automatically generated. |
* SnapshotScannerHDFSAclController won't handle HDFS acls for users with table read permission | ||
* @return true if user scan snapshot is enabled for this table | ||
*/ | ||
boolean isUserScanSnapshotEnabled(); |
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 TableDescriptor is @InterfaceAudience.Public interfaces, right ? and the snapshot acl is a optional coproccesor ...
I think we can not add an extra specific method in the PUBLIC interface, once someone use this method, then devs can not remove or change this easily, we MUST deprecated it in a old major release, then remove it in another new major release. It is troublesome.
fec069d
to
5160c62
Compare
} | ||
|
||
boolean isTableUserScanSnapshotEnabled(TableDescriptor tableDescriptor) { | ||
return tableDescriptor.getCoprocessorDescriptors().stream() |
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.
Just use the TableDescriptor#hasCoprocessor ?
if (checkTable(currentDescriptor, () -> "modifyTable " + tableName) | ||
&& !hdfsAclHelper.isTableUserScanSnapshotEnabled(oldDescriptor)) { | ||
hdfsAclHelper.createTableDirectories(tableName); | ||
Set<String> users = new HashSet<>(); |
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.
Abstract an small method here ? I saw many places has the logic: to pick up all the users who has the read permission on table / ns / global etc...
hdfsAclHelper.getUsersWithTableReadAction(tableName); | ||
users.addAll(userWithTableReadPermission); | ||
hdfsAclHelper.addTableAcl(tableName, users); | ||
try (Table aclTable = |
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.
Also can abstract a method for the flag updating
💔 -1 overall
This message was automatically generated. |
5160c62
to
f18b3bb
Compare
🎊 +1 overall
This message was automatically generated. |
.../src/main/java/org/apache/hadoop/hbase/security/access/SnapshotScannerHDFSAclController.java
Outdated
Show resolved
Hide resolved
@@ -513,12 +518,33 @@ private boolean isHdfsAclSet(Table aclTable, String userName, String namespace, | |||
return isSet; | |||
} | |||
|
|||
private boolean checkInitialized() { | |||
@VisibleForTesting | |||
boolean checkInitialized(Supplier<String> operation) { |
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.
Just use the string as the argument ? I don't think here we need the Supplier wrapper ...
&& hdfsAclHelper.checkTablePermissionHasNoCfOrCq(tablePermission); | ||
} | ||
|
||
private boolean needSetTableHdfsAcl(TableName tableName, Supplier<String> operation) |
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.
Also can remoe the Supplier wrapper ?
return userPermission.getPermission().implies(Permission.Action.READ); | ||
} | ||
|
||
boolean checkTablePermissionHasNoCfOrCq(TablePermission tablePermission) { |
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.
checkTablePermissionHasNoCfOrCq - > isFamilyOrColumnPermission ?
return it as : tablePermission.hasFamily() || tablePermission.hasQualifier()
.
|
||
boolean isTableUserScanSnapshotEnabled(TableDescriptor tableDescriptor) { | ||
String value = tableDescriptor.getValue(USER_SCAN_SNAPSHOT_ENABLE); | ||
if (value != null && value.equals("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.
Just :
return Boolean.valueOf(value) ?
tableUsers, tableName); | ||
} else if (!aclTableInitialized | ||
&& Bytes.equals(PermissionStorage.ACL_GLOBAL_NAME, tableName.getName())) { | ||
aclTableInitialized = 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.
Oh, you update the aclTableInitialized here when add HDFS_ACL_FAMILY in hbase:acl ? Why just update the flag once the modifyTable called successfully ? I think that will be easy to understand.
} | ||
|
||
boolean isTableUserScanSnapshotEnabled(TableDescriptor tableDescriptor) { | ||
String value = tableDescriptor.getValue(USER_SCAN_SNAPSHOT_ENABLE); |
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 flag should mean whether will we sync the table access to HDFS files ACL ? I think we should a more clear name ?
f18b3bb
to
4da7e94
Compare
hdfsAclHelper.addTableAcl(tableName, users); | ||
SnapshotScannerHDFSAclStorage.addUserTableHdfsAcl(ctx.getEnvironment().getConnection(), | ||
tableUsers, tableName); | ||
} |
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 it will happen if we have an TableUserScanSnapshot Enabled table, and then modify to disabled ? I think we shold also remove the HDFS ACL ?
💔 -1 overall
This message was automatically generated. |
4da7e94
to
e6ed33b
Compare
🎊 +1 overall
This message was automatically generated. |
admin.modifyTable(builder.build()); | ||
} | ||
// wait until acl table is online | ||
List<RegionInfo> tableRegions = MetaTableAccessor.getTableRegions( |
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 to wait & assign the hbase:acl region ? In theory, the modifyTable will ensure that all of the regions are online.
@@ -515,6 +560,18 @@ private static AclEntry aclEntry(AclEntryScope scope, String name) { | |||
.setPermission(READ_EXECUTE).build(); | |||
} | |||
|
|||
void createNonExistDir(Path path) throws 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.
createDirIfNotExist.
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
e6ed33b
to
531c054
Compare
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
…configurable for table
531c054
to
5c8a26f
Compare
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…configurable for table (#336)
…configurable for table (apache#336)
No description provided.