Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Table Access Control is not enabled on this cluster" error #2167

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replicating the broad exception catching from grants() method

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
Loading