Skip to content

Commit eb6037c

Browse files
committed
Rework missing principle checks
1 parent b034a93 commit eb6037c

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

dbclient/WorkspaceClient.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,10 @@ def apply_acl_on_object(self, acl_str, error_logger, checkpoint_key_set):
665665
api_args = {'access_control_list': access_control_list}
666666
resp = self.patch(api_path, api_args)
667667

668+
# if skipping non-existing users, add error code to allowlist
669+
ignore_error_list = wmconstants.IGNORE_ERROR_LIST
668670
if self.skip_missing_users:
669-
ignore_error_list = ["RESOURCE_DOES_NOT_EXIST", "RESOURCE_ALREADY_EXISTS"]
670-
else:
671-
ignore_error_list = ["RESOURCE_ALREADY_EXISTS"]
671+
ignore_error_list.append("RESOURCE_DOES_NOT_EXIST")
672672

673673
if logging_utils.check_error(resp, ignore_error_list):
674674
logging_utils.log_response_error(error_logger, resp)

logging_utils.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44
import re
5+
import wmconstants
56

67

78
def set_default_logging(parent_dir, level=logging.INFO):
@@ -39,18 +40,17 @@ def get_error_log_file(action_type, object_type, parent_dir):
3940
def _get_log_dir(parent_dir):
4041
return parent_dir + "/app_logs"
4142

42-
default_ignore_error_list=[
43-
'RESOURCE_ALREADY_EXISTS'
44-
]
45-
4643

4744
def log_response_error(error_logger,
48-
response,
49-
error_msg=None,
50-
ignore_error_list=default_ignore_error_list):
45+
response,
46+
error_msg=None,
47+
ignore_error_list=None):
5148
"""
5249
Logs errors based on the response. Usually used when the response is the http response.
5350
"""
51+
if ignore_error_list is None:
52+
ignore_error_list = wmconstants.IGNORE_ERROR_LIST
53+
5454
if check_error(response, ignore_error_list):
5555
if error_msg:
5656
error_logger.error(error_msg)
@@ -61,10 +61,14 @@ def log_response_error(error_logger,
6161
return False
6262

6363

64-
def check_error(response, ignore_error_list=default_ignore_error_list):
64+
def check_error(response, ignore_error_list=None):
65+
if ignore_error_list is None:
66+
ignore_error_list = wmconstants.IGNORE_ERROR_LIST
67+
6568
if type(response) is list:
6669
for resp in response:
67-
if (_check_error_helper(resp, ignore_error_list)): return True
70+
if _check_error_helper(resp, ignore_error_list):
71+
return True
6872
return False
6973
else:
7074
return _check_error_helper(response, ignore_error_list)
@@ -75,11 +79,6 @@ def _check_error_helper(response, ignore_error_list):
7579
if re.match("Cluster .*? is in unexpected state (Running|Pending)\\.", response.get("message", "")):
7680
return False
7781

78-
# suppress principal error; this should be surfaced from the client level
79-
if re.match("Principal: .*? does not exist", response.get("message", "")) \
80-
and (response.get("error_code") == "RESOURCE_DOES_NOT_EXIST"):
81-
return False
82-
8382
return ('error_code' in response and response['error_code'] not in ignore_error_list) \
8483
or ('error' in response and response['error'] not in ignore_error_list) \
8584
or (response.get('resultType', None) == 'error' and 'already exists' not in response.get('summary', None))

wmconstants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
MLFLOW_EXPERIMENT_OBJECT = "mlflow_experiments"
2020
MLFLOW_EXPERIMENT_PERMISSION_OBJECT = "mlflow_experiments_permissions"
2121
MLFLOW_RUN_OBJECT = "mlflow_runs"
22+
2223
# Migration pipeline placeholder constants
2324
MIGRATION_PIPELINE_OBJECT_TYPE = "tasks"
25+
IGNORE_ERROR_LIST = ['RESOURCE_ALREADY_EXISTS', 'FEATURE_DISABLED']
2426

2527
# Actions
2628
WM_EXPORT = "export"

0 commit comments

Comments
 (0)