Repository: sentry Updated Branches: refs/heads/sentry-ha-redesign 27117ac61 -> 218be0c59
SENTRY-1345: ACLS on table folder disappear after insert for unpartitioned tables (Sravya Tirukkovalur, Reviewed by: Hao Hao and Anne Yu) Project: http://git-wip-us.apache.org/repos/asf/sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/65568d3c Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/65568d3c Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/65568d3c Branch: refs/heads/sentry-ha-redesign Commit: 65568d3c0e75c2a71e303877ced0e5e80b7e4301 Parents: 27117ac Author: Alexander Kolbasov <[email protected]> Authored: Fri Mar 10 21:49:33 2017 -0800 Committer: Alexander Kolbasov <[email protected]> Committed: Fri Mar 10 21:49:33 2017 -0800 ---------------------------------------------------------------------- .../SentryMetastorePostEventListener.java | 4 ++- .../tests/e2e/hdfs/TestHDFSIntegration.java | 29 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sentry/blob/65568d3c/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java ---------------------------------------------------------------------- diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java index fdb6df4..51eebd9 100644 --- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java +++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java @@ -408,8 +408,10 @@ public class SentryMetastorePostEventListener extends MetaStoreEventListener { } // The HDFS plugin needs to know if it's a path change (set location) for (SentryMetastoreListenerPlugin plugin : sentryPlugins) { - plugin.renameAuthzObject(oldDbName + "." + oldTabName, oldPath, + if(!oldPath.equals(newPath)) { + plugin.renameAuthzObject(oldDbName + "." + oldTabName, oldPath, newDbName + "." + newTabName, newPath); + } } } http://git-wip-us.apache.org/repos/asf/sentry/blob/65568d3c/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java index c3bb118..73d5477 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java @@ -540,6 +540,35 @@ public class TestHDFSIntegration { } @Test + public void testNoPartitionInsert() throws Throwable { + tmpHDFSDir = new Path("/tmp/external"); + dbNames = new String[]{"db1"}; + roles = new String[]{"admin_role", "tab_role"}; + admin = "hive"; + + Connection conn; + Statement stmt; + conn = hiveServer2.createConnection("hive", "hive"); + stmt = conn.createStatement(); + stmt.execute("create role admin_role"); + stmt.execute("grant role admin_role to group hive"); + stmt.execute("grant all on server server1 to role admin_role"); + + //Create table and grant select to user flume + stmt.execute("create database db1"); + stmt.execute("use db1"); + stmt.execute("create table t1 (s string)"); + stmt.execute("create role tab_role"); + stmt.execute("grant select on table t1 to role tab_role"); + stmt.execute("grant role tab_role to group flume"); + + verifyOnAllSubDirs("/user/hive/warehouse/db1.db/t1", FsAction.READ_EXECUTE, "flume", true); + stmt.execute("INSERT INTO TABLE t1 VALUES (1)"); + verifyOnAllSubDirs("/user/hive/warehouse/db1.db/t1", FsAction.READ_EXECUTE, "flume", true); + + } + + @Test public void testEnd2End() throws Throwable { tmpHDFSDir = new Path("/tmp/external"); dbNames = new String[]{"db1"};
