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

Add --skip-acls option for exporting. #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 9 additions & 6 deletions dbclient/ClustersClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,23 +607,26 @@ def log_cluster_configs(self, log_file='clusters.log', acl_log_file='acl_cluster
cluster_json['aws_attributes'] = aws_conf
cluster_perms = self.get_cluster_acls(cluster_json['cluster_id'], cluster_json['cluster_name'])

args = parser.get_pipeline_parser().parse_args()

if users_list:
acls = [acl for acl in cluster_perms.get("access_control_list") if
(acl.get("group_name", "") in self.groups_to_keep) or
(acl.get("user_name", "") in users_list) or
(acl.get("group_name", "") == "users")]
cluster_perms["access_control_list"] = acls

if cluster_perms['http_status_code'] == 200 and acls:
if not args.skip_acls:
if cluster_perms['http_status_code'] == 200 and acls:
acl_log_fp.write(json.dumps(cluster_perms) + '\n')
else:
error_logger.error(f'Failed to get cluster ACL: {cluster_perms}')
elif not args.skip_acls:
if cluster_perms['http_status_code'] == 200:
acl_log_fp.write(json.dumps(cluster_perms) + '\n')
else:
error_logger.error(f'Failed to get cluster ACL: {cluster_perms}')

elif cluster_perms['http_status_code'] == 200:
acl_log_fp.write(json.dumps(cluster_perms) + '\n')
else:
error_logger.error(f'Failed to get cluster ACL: {cluster_perms}')

if filter_user:
if cluster_json['creator_user_name'] == filter_user:
log_fp.write(json.dumps(cluster_json) + '\n')
Expand Down
6 changes: 6 additions & 0 deletions dbclient/JobsClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ def log_job_configs(self, users_list=None, groups_list = None, log_file='jobs.lo
# reset the original struct with the new settings
x['settings'] = job_settings

args = parser.get_pipeline_parser().parse_args()

if args.skip_acls:
log_fp.write(json.dumps(x) + '\n')
continue

# get ACLs and check that the job has one owner before writing
job_perms = self.get(f'/preview/permissions/jobs/{job_id}')
if not logging_utils.log_response_error(error_logger, job_perms):
Expand Down
3 changes: 3 additions & 0 deletions dbclient/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ def get_pipeline_parser() -> argparse.ArgumentParser:
parser.add_argument('--keep-tasks', nargs='+', type=str, action=ValidateSkipTasks, default=[],
help='List of tasks to run in the pipeline; overrides --skip-tasks.')

parser.add_argument('--skip-acls', action='store_true',
help='Skip exporting ACLs whose absence may cause errors.')

parser.add_argument('--num-parallel', type=int, default=4, help='Number of parallel threads to use to '
'export/import')

Expand Down
6 changes: 6 additions & 0 deletions migration_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ def build_export_pipeline(client_config, checkpoint_service, args) -> Pipeline:
else:
skip_tasks = args.skip_tasks

if args.skip_acls:
skip_tasks.append(wmconstants.WORKSPACE_ACLS)
skip_tasks.append(wmconstants.METASTORE_TABLE_ACLS)

skip_tasks = list(set(skip_tasks))

source_info_file = os.path.join(client_config['export_dir'], "source_info.txt")
with open(source_info_file, 'w') as f:
f.write(client_config['url'])
Expand Down