Skip to content

Commit

Permalink
Fixed "Table Access Control is not enabled on this cluster" error (#2167
Browse files Browse the repository at this point in the history
)

## 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]>
  • Loading branch information
ericvergnaud and ericvergnaud authored Jul 12, 2024
1 parent 5214c83 commit b72b6e5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/databricks/labs/ucx/hive_metastore/grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ def uc_grant_sql(self, object_type: str | None = None, object_key: str | None =
return make_query(object_type, object_key)


CLUSTER_WITHOUT_ACL_FRAGMENT = "Table Access Control is not enabled on this cluster"


class GrantsCrawler(CrawlerBase[Grant]):
def __init__(self, tc: TablesCrawler, udf: UdfsCrawler, include_databases: list[str] | None = None):
assert tc._backend == udf._backend
Expand All @@ -198,7 +201,12 @@ def __init__(self, tc: TablesCrawler, udf: UdfsCrawler, include_databases: list[
self._include_databases = include_databases

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

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


Expand Down

0 comments on commit b72b6e5

Please sign in to comment.