From 6c7b4e2a162c91dd9943db85148e44c599199004 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Mon, 23 Nov 2026 12:40:19 -0800 Subject: [PATCH] PHOENIX-8118 BasePermissionsIT should wait for the master and custom AccessController ACL caches updateACLs waits until the AuthManager of each AccessController sees the ACL change. The helper found controllers by exact class name, so it found none when the cluster loads a subclass of AccessController. It also scanned only the region servers and skipped the master. The master checks GRANT and REVOKE requests against its own cache, which ZooKeeper refreshes asynchronously. A deny check right after REVOKE could thus pass on a stale master cache and the test failed with "Expected exception was not thrown". Look up controllers by class type, so that subclasses match, and include the master controller in the wait. The deny checks are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../phoenix/end2end/BasePermissionsIT.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java index e3fc2ac9ee0..ae85552b2ad 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java @@ -1797,14 +1797,20 @@ public void getUserPermissions(RpcController controller, } } - // Copied from org.apache.hadoop.hbase.security.access.SecureTestUtil because it's not visible - // there + // Based on org.apache.hadoop.hbase.security.access.SecureTestUtil, which is not visible here. private static List getAccessControllers(MiniHBaseCluster cluster) { List result = Lists.newArrayList(); + // The master checks grant, revoke and DDL requests against its own permission cache. + // Thus the wait must also include the master. + // The lookup uses the class type. Thus it also finds subclasses of AccessController. + AccessController masterAc = + cluster.getMaster().getMasterCoprocessorHost().findCoprocessor(AccessController.class); + if (masterAc != null) { + result.add(masterAc); + } for (RegionServerThread t : cluster.getLiveRegionServerThreads()) { for (HRegion region : t.getRegionServer().getOnlineRegionsLocalContext()) { - Coprocessor cp = - region.getCoprocessorHost().findCoprocessor(AccessController.class.getName()); + Coprocessor cp = region.getCoprocessorHost().findCoprocessor(AccessController.class); if (cp != null) { result.add((AccessController) cp); } @@ -1813,6 +1819,13 @@ private static List getAccessControllers(MiniHBaseCluster clus return result; } + // Identify the controller in log messages. The master controller has no region. + private static String describe(AccessController ac) { + return ac.getRegion() == null + ? "master" + : "region " + ac.getRegion().getRegionInfo().getRegionNameAsString(); + } + // Copied from org.apache.hadoop.hbase.security.access.SecureTestUtil because it's not visible // there private static Map getAuthManagerMTimes(MiniHBaseCluster cluster) { @@ -1840,17 +1853,16 @@ public boolean evaluate() { Map mtimes = getAuthManagerMTimes(util.getHBaseCluster()); for (Map.Entry e : mtimes.entrySet()) { if (!oldMTimes.containsKey(e.getKey())) { - LOGGER.error("Snapshot of AccessController state does not include instance on region " - + e.getKey().getRegion().getRegionInfo().getRegionNameAsString()); + LOGGER.error("Snapshot of AccessController state does not include instance on " + + describe(e.getKey())); // Error out the predicate, we will try again return false; } long old = oldMTimes.get(e.getKey()); long now = e.getValue(); if (now <= old) { - LOGGER.info("AccessController on region " - + e.getKey().getRegion().getRegionInfo().getRegionNameAsString() - + " has not updated: mtime=" + now); + LOGGER.info( + "AccessController on " + describe(e.getKey()) + " has not updated: mtime=" + now); return false; } }