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

Return False when failed to migrate table #2982

Merged

Conversation

JCZuurmond
Copy link
Contributor

Return False when failed to migrate.

@JCZuurmond JCZuurmond added bug Something isn't working migrate/managed go/uc/upgrade Upgrade Managed Tables and Jobs internal this pull request won't appear in release notes labels Oct 16, 2024
@JCZuurmond JCZuurmond self-assigned this Oct 16, 2024
@JCZuurmond JCZuurmond requested a review from a team as a code owner October 16, 2024 11:56
@JCZuurmond JCZuurmond marked this pull request as draft October 16, 2024 11:56
@JCZuurmond
Copy link
Contributor Author

@FastLee : See the following code that you introduced in PR:

except NotFound:
# If the source table doesn't exist, it will not be shown as migrated
logger.warning(f"failed-to-migrate: {schema}.{table} set as a source does no longer exist")
return True

The comment contradicts the return statement, should it be return False instead?

@JCZuurmond
Copy link
Contributor Author

@nfx and @FastLee : In migrate grants we have:

def apply(self, src: Table, uc_table_key: str) -> bool:
for grant in self._match_grants(src):
acl_migrate_sql = grant.uc_grant_sql(src.kind, uc_table_key)
if acl_migrate_sql is None:
logger.warning(
f"failed-to-migrate: Hive metastore grant '{grant.action_type}' cannot be mapped to UC grant for "
f"{src.kind} '{uc_table_key}'. Skipping."
)
continue
logger.debug(f"Migrating acls on {uc_table_key} using SQL query: {acl_migrate_sql}")
try:
self._sql_backend.execute(acl_migrate_sql)
except DatabricksError as e:
logger.warning(f"failed-to-migrate: Failed to migrate ACL for {src.key} to {uc_table_key}: {e}")
return True

I understand we skip some unmappable grants (e.g. READ_METADATA):

acl_migrate_sql = grant.uc_grant_sql(src.kind, uc_table_key)
if acl_migrate_sql is None:
logger.warning(
f"failed-to-migrate: Hive metastore grant '{grant.action_type}' cannot be mapped to UC grant for "
f"{src.kind} '{uc_table_key}'. Skipping."
)
continue

However, should we consider the migration successful when a mappable grant can not be executed?

try:
self._sql_backend.execute(acl_migrate_sql)
except DatabricksError as e:
logger.warning(f"failed-to-migrate: Failed to migrate ACL for {src.key} to {uc_table_key}: {e}")

I would argue the migration is unsuccessful, thus return False

Copy link

github-actions bot commented Oct 16, 2024

✅ 53/53 passed, 1 flaky, 4 skipped, 1h44m7s total

Flaky tests:

  • 🤪 test_migration_job_ext_hms[regular] (6m16.414s)

Running from acceptance #6854

@nfx nfx requested a review from FastLee October 16, 2024 12:59
@FastLee
Copy link
Contributor

FastLee commented Oct 17, 2024

@nfx and @FastLee : In migrate grants we have:

def apply(self, src: Table, uc_table_key: str) -> bool:
for grant in self._match_grants(src):
acl_migrate_sql = grant.uc_grant_sql(src.kind, uc_table_key)
if acl_migrate_sql is None:
logger.warning(
f"failed-to-migrate: Hive metastore grant '{grant.action_type}' cannot be mapped to UC grant for "
f"{src.kind} '{uc_table_key}'. Skipping."
)
continue
logger.debug(f"Migrating acls on {uc_table_key} using SQL query: {acl_migrate_sql}")
try:
self._sql_backend.execute(acl_migrate_sql)
except DatabricksError as e:
logger.warning(f"failed-to-migrate: Failed to migrate ACL for {src.key} to {uc_table_key}: {e}")
return True

I understand we skip some unmappable grants (e.g. READ_METADATA):

acl_migrate_sql = grant.uc_grant_sql(src.kind, uc_table_key)
if acl_migrate_sql is None:
logger.warning(
f"failed-to-migrate: Hive metastore grant '{grant.action_type}' cannot be mapped to UC grant for "
f"{src.kind} '{uc_table_key}'. Skipping."
)
continue

However, should we consider the migration successful when a mappable grant can not be executed?

try:
self._sql_backend.execute(acl_migrate_sql)
except DatabricksError as e:
logger.warning(f"failed-to-migrate: Failed to migrate ACL for {src.key} to {uc_table_key}: {e}")

I would argue the migration is unsuccessful, thus return False

I would argue we have to keep it as True. We may want to consider ACL migration status.

Copy link
Contributor

@FastLee FastLee left a comment

Choose a reason for hiding this comment

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

LGTM

@FastLee
Copy link
Contributor

FastLee commented Oct 17, 2024

@FastLee : See the following code that you introduced in PR:

except NotFound:
# If the source table doesn't exist, it will not be shown as migrated
logger.warning(f"failed-to-migrate: {schema}.{table} set as a source does no longer exist")
return True

The comment contradicts the return statement, should it be return False instead?

This is a case where the old table is removed. The migration status should be successful. Otherwise we will not be able to migrate views.

@JCZuurmond
Copy link
Contributor Author

This is a case where the old table is removed. The migration status should be successful. Otherwise we will not be able to migrate views.

Oke, then I will update the comment as that is not what is says

@JCZuurmond JCZuurmond force-pushed the fix/failed-to-migrate-should-return-false-for-table-migration branch from b856343 to 1ad44ca Compare October 17, 2024 13:59
@nfx nfx merged commit 6ff3621 into main Oct 17, 2024
7 checks passed
@nfx nfx deleted the fix/failed-to-migrate-should-return-false-for-table-migration branch October 17, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internal this pull request won't appear in release notes migrate/managed go/uc/upgrade Upgrade Managed Tables and Jobs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants