Skip to content

HBASE-21995 Add a coprocessor to set HDFS ACL for hbase granted user - #163

Merged
mymeiyi merged 1 commit into
apache:masterfrom
mymeiyi:hdfs-acl
Jun 24, 2019
Merged

HBASE-21995 Add a coprocessor to set HDFS ACL for hbase granted user#163
mymeiyi merged 1 commit into
apache:masterfrom
mymeiyi:hdfs-acl

Conversation

@mymeiyi

Copy link
Copy Markdown
Contributor

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:

  1. For public directories such as 'data' and 'archive', set other users' permission to '--x' to make everyone have the permission to access the directory.
  2. For namespace or table directories such as 'data/ns/table', 'archive/data/ns/table' and '.hbase-snapshot/snapshotName', set user 'r-x' acl and default 'r-x' acl when grant, revoke, snapshot.
    The feature is configurable because it's implemented in a master coprocessor.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec394Docker mode activated.
_ Prechecks _
+1hbaseanti0Patch does not have any anti-patterns.
+1@author0The patch does not contain any @author tags.
+1test4tests0The patch appears to include 1 new or modified test files.
_ master Compile Tests _
+1mvninstall302master passed
+1compile55master passed
+1checkstyle72master passed
+1shadedjars281branch has no errors when building our shaded downstream artifacts.
+1findbugs215master passed
+1javadoc34master passed
_ Patch Compile Tests _
+1mvninstall258the patch passed
+1compile53the patch passed
+1javac53the patch passed
-1checkstyle67hbase-server: The patch generated 3 new + 51 unchanged - 2 fixed = 54 total (was 53)
+1whitespace0The patch has no whitespace issues.
+1shadedjars269patch has no errors when building our shaded downstream artifacts.
+1hadoopcheck554Patch does not cause any errors with Hadoop 2.7.4 or 3.0.0.
+1findbugs213the patch passed
+1javadoc34the patch passed
_ Other Tests _
-1unit12876hbase-server in the patch failed.
+1asflicense28The patch does not generate ASF License warnings.
15781
ReasonTests
Failed junit testshadoop.hbase.client.TestFromClientSide
SubsystemReport/Notes
DockerClient=17.05.0-ce Server=17.05.0-ce base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/1/artifact/out/Dockerfile
GITHUB PR#163
Optional Testsdupname asflicense javac javadoc unit findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 495d4df97ab4 4.4.0-137-generic #163-Ubuntu SMP Mon Sep 24 13:14:43 UTC 2018 x86_64 GNU/Linux
Build toolmaven
Personality/testptch/patchprocess/precommit/personality/provided.sh
git revisionmaster / 428afa9
mavenversion: Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T18:33:14Z)
Default Java1.8.0_181
findbugsv3.1.11
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/1/artifact/out/diff-checkstyle-hbase-server.txt
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/1/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/1/testReport/
Max. process+thread count4769 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/1/console
Powered byApache Yetus 0.9.0 http://yetus.apache.org

This message was automatically generated.

return(in);
} catch (FileNotFoundException e) {
// Try another file location
} catch (AccessControlException e) {

Copy link
Copy Markdown
Member

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:

  1. remember the thrown exception as e;
  2. if notfound or accessControl exception, continue to try another file;
  3. if still not find an right file. then throw the e.
    Please consider this.

Copy link
Copy Markdown
Member

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 ?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return fs.getFileStatus(locations[i]);
} catch (FileNotFoundException e) {
// Try another file location
} catch (AccessControlException e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question above.

Copy link
Copy Markdown
ContributorAuthor

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 {

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
ContributorAuthor

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)

Copy link
Copy Markdown
Member

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 ?

Copy link
Copy Markdown
ContributorAuthor

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");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalArgumentException ?

Copy link
Copy Markdown
ContributorAuthor

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);

Copy link
Copy Markdown
Member

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 ?

Copy link
Copy Markdown
ContributorAuthor

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());
}
}

Copy link
Copy Markdown
Member

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 ?

@mymeiyimymeiyiMay 15, 2019

Copy link
Copy Markdown
ContributorAuthor

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);

Copy link
Copy Markdown
Member

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 ?

Copy link
Copy Markdown
ContributorAuthor

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:

  1. check if we need to remove hdfs acls for a grant without READ permission;
  2. skip some hdfs acl sync because it may be already added.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec38Docker mode activated.
_ Prechecks _
+1hbaseanti0Patch does not have any anti-patterns.
+1@author0The patch does not contain any @author tags.
+1test4tests0The patch appears to include 1 new or modified test files.
_ master Compile Tests _
+1mvninstall310master passed
+1compile67master passed
+1checkstyle85master passed
+1shadedjars337branch has no errors when building our shaded downstream artifacts.
+1findbugs287master passed
+1javadoc41master passed
_ Patch Compile Tests _
+1mvninstall302the patch passed
+1compile68the patch passed
+1javac68the patch passed
-1checkstyle83hbase-server: The patch generated 3 new + 51 unchanged - 2 fixed = 54 total (was 53)
+1whitespace0The patch has no whitespace issues.
+1shadedjars339patch has no errors when building our shaded downstream artifacts.
+1hadoopcheck621Patch does not cause any errors with Hadoop 2.7.4 or 3.0.0.
+1findbugs298the patch passed
+1javadoc40the patch passed
_ Other Tests _
+1unit14069hbase-server in the patch passed.
+1asflicense31The patch does not generate ASF License warnings.
17083
SubsystemReport/Notes
DockerClient=17.05.0-ce Server=17.05.0-ce base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/2/artifact/out/Dockerfile
GITHUB PR#163
Optional Testsdupname asflicense javac javadoc unit findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 3763afd5e56d 4.4.0-138-generic #164-Ubuntu SMP Tue Oct 2 17:16:02 UTC 2018 x86_64 GNU/Linux
Build toolmaven
Personality/testptch/patchprocess/precommit/personality/provided.sh
git revisionmaster / f30d6c9
mavenversion: Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T18:33:14Z)
Default Java1.8.0_181
findbugsv3.1.11
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/2/artifact/out/diff-checkstyle-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/2/testReport/
Max. process+thread count4655 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/2/console
Powered byApache Yetus 0.9.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec0Docker mode activated.
-1patch7#163 does not apply to master. Rebase required? Wrong Branch? See https://yetus.apache.org/documentation/in-progress/precommit-patchnames for help.
SubsystemReport/Notes
GITHUB PR#163
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/3/console
Powered byApache Yetus 0.9.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec58Docker mode activated.
_ Prechecks _
+1hbaseanti0Patch does not have any anti-patterns.
+1@author0The patch does not contain any @author tags.
+1test4tests0The patch appears to include 1 new or modified test files.
_ master Compile Tests _
+1mvninstall331master passed
+1compile58master passed
+1checkstyle72master passed
+1shadedjars289branch has no errors when building our shaded downstream artifacts.
+1findbugs228master passed
+1javadoc36master passed
_ Patch Compile Tests _
+1mvninstall259the patch passed
+1compile60the patch passed
+1javac60the patch passed
-1checkstyle76hbase-server: The patch generated 4 new + 51 unchanged - 2 fixed = 55 total (was 53)
+1whitespace0The patch has no whitespace issues.
+1shadedjars275patch has no errors when building our shaded downstream artifacts.
+1hadoopcheck601Patch does not cause any errors with Hadoop 2.7.4 or 3.0.0.
-1findbugs239hbase-server generated 1 new + 0 unchanged - 0 fixed = 1 total (was 0)
+1javadoc34the patch passed
_ Other Tests _
-1unit20409hbase-server in the patch failed.
+1asflicense31The patch does not generate ASF License warnings.
23451
ReasonTests
FindBugsmodule:hbase-server
Exception is caught when Exception is not thrown in org.apache.hadoop.hbase.security.access.HDFSAclHelper.grant(byte[], Set) At HDFSAclHelper.java:is not thrown in org.apache.hadoop.hbase.security.access.HDFSAclHelper.grant(byte[], Set) At HDFSAclHelper.java:[line 152]
Failed junit testshadoop.hbase.master.TestMasterMetricsWrapper
hadoop.hbase.security.access.TestHDFSAclController
hadoop.hbase.client.TestSnapshotTemporaryDirectoryWithRegionReplicas
hadoop.hbase.client.TestHbck
hadoop.hbase.client.TestFromClientSide3
hadoop.hbase.master.procedure.TestTruncateTableProcedure
hadoop.hbase.tool.TestLoadIncrementalHFiles
hadoop.hbase.master.TestAssignmentManagerMetrics
hadoop.hbase.client.TestAdmin1
hadoop.hbase.client.replication.TestReplicationAdminWithClusters
hadoop.hbase.master.procedure.TestProcedurePriority
hadoop.hbase.replication.TestReplicationSyncUpTool
hadoop.hbase.namespace.TestNamespaceAuditor
hadoop.hbase.replication.TestReplicationSmallTestsSync
hadoop.hbase.client.TestFromClientSide
hadoop.hbase.master.TestSplitWALManager
hadoop.hbase.master.procedure.TestSCPWithoutZKCoordinated
hadoop.hbase.client.TestFromClientSideWithCoprocessor
hadoop.hbase.util.TestFromClientSide3WoUnsafe
hadoop.hbase.client.TestSnapshotDFSTemporaryDirectory
hadoop.hbase.tool.TestSecureLoadIncrementalHFiles
hadoop.hbase.client.TestSnapshotTemporaryDirectory
hadoop.hbase.replication.TestReplicationSmallTests
SubsystemReport/Notes
DockerClient=17.05.0-ce Server=17.05.0-ce base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/4/artifact/out/Dockerfile
GITHUB PR#163
Optional Testsdupname asflicense javac javadoc unit findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux b3efbe6fa87c 4.4.0-138-generic #164-Ubuntu SMP Tue Oct 2 17:16:02 UTC 2018 x86_64 GNU/Linux
Build toolmaven
Personality/testptch/patchprocess/precommit/personality/provided.sh
git revisionmaster / 67c937f
mavenversion: Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T18:33:14Z)
Default Java1.8.0_181
findbugsv3.1.11
checkstylehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/4/artifact/out/diff-checkstyle-hbase-server.txt
findbugshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/4/artifact/out/new-findbugs-hbase-server.html
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/4/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/4/testReport/
Max. process+thread count5240 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/4/console
Powered byApache Yetus 0.9.0 http://yetus.apache.org

This message was automatically generated.

@openinx

Copy link
Copy Markdown
Member

@mymeiyi Please check the failed UT.

@Apache9

Copy link
Copy Markdown
Contributor

Any updates here?

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec0Docker mode activated.
-1patch10#163 does not apply to master. Rebase required? Wrong Branch? See https://yetus.apache.org/documentation/in-progress/precommit-patchnames for help.
SubsystemReport/Notes
GITHUB PR#163
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/5/console
Powered byApache Yetus 0.9.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec0Docker mode activated.
-1patch8#163 does not apply to master. Rebase required? Wrong Branch? See https://yetus.apache.org/documentation/in-progress/precommit-patchnames for help.
SubsystemReport/Notes
GITHUB PR#163
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/6/console
Powered byApache Yetus 0.9.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec0Docker mode activated.
-1patch6#163 does not apply to master. Rebase required? Wrong Branch? See https://yetus.apache.org/documentation/in-progress/precommit-patchnames for help.
SubsystemReport/Notes
GITHUB PR#163
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-163/7/console
Powered byApache Yetus 0.9.0 http://yetus.apache.org

This message was automatically generated.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@mymeiyi@Apache-HBase@openinx@Apache9@infraio