Skip to content

Commit b72b6e5

Browse files
authored
Fixed "Table Access Control is not enabled on this cluster" error (#2167)
## Changes log warning instead of error when this exception is raised ### Linked issues Resolves #1957 ### Functionality None ### Tests Not tested See comments in #1957 re the proposed resolution approach Co-authored-by: Eric Vergnaud <[email protected]>
1 parent 5214c83 commit b72b6e5

File tree

1 file changed

+12
-3
lines changed
  • src/databricks/labs/ucx/hive_metastore

1 file changed

+12
-3
lines changed

src/databricks/labs/ucx/hive_metastore/grants.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ def uc_grant_sql(self, object_type: str | None = None, object_key: str | None =
187187
return make_query(object_type, object_key)
188188

189189

190+
CLUSTER_WITHOUT_ACL_FRAGMENT = "Table Access Control is not enabled on this cluster"
191+
192+
190193
class GrantsCrawler(CrawlerBase[Grant]):
191194
def __init__(self, tc: TablesCrawler, udf: UdfsCrawler, include_databases: list[str] | None = None):
192195
assert tc._backend == udf._backend
@@ -198,7 +201,12 @@ def __init__(self, tc: TablesCrawler, udf: UdfsCrawler, include_databases: list[
198201
self._include_databases = include_databases
199202

200203
def snapshot(self) -> Iterable[Grant]:
201-
return self._snapshot(partial(self._try_load), partial(self._crawl))
204+
try:
205+
return self._snapshot(partial(self._try_load), partial(self._crawl))
206+
except Exception as e: # pylint: disable=broad-exception-caught
207+
log_fn = logger.warning if CLUSTER_WITHOUT_ACL_FRAGMENT in repr(e) else logger.error
208+
log_fn(f"Couldn't fetch grants snapshot: {e}")
209+
return []
202210

203211
def _try_load(self):
204212
for row in self._fetch(f"SELECT * FROM {escape_sql_identifier(self.full_name)}"):
@@ -354,11 +362,12 @@ def grants(
354362
grants.append(grant)
355363
return grants
356364
except NotFound:
357-
# This make the integration test more robust as many test schemas are being created and deleted quickly.
365+
# This makes the integration test more robust as many test schemas are being created and deleted quickly.
358366
logger.warning(f"Schema {catalog}.{database} no longer existed")
359367
return []
360368
except Exception as e: # pylint: disable=broad-exception-caught
361-
logger.error(f"Couldn't fetch grants for object {on_type} {key}: {e}")
369+
log_fn = logger.warning if CLUSTER_WITHOUT_ACL_FRAGMENT in repr(e) else logger.error
370+
log_fn(f"Couldn't fetch grants for object {on_type} {key}: {e}")
362371
return []
363372

364373

0 commit comments

Comments
 (0)