Skip to content

Commit d093eb8

Browse files
manage the acl_jobs error log properly
1 parent 93a91d8 commit d093eb8

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

dbclient/JobsClient.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ def log_job_configs(self, users_list=None, groups_list = None, log_file='jobs.lo
100100
jobs_log = self.get_export_dir() + log_file
101101
acl_jobs_log = self.get_export_dir() + acl_file
102102
error_logger = logging_utils.get_error_logger(wmconstants.WM_EXPORT, wmconstants.JOB_OBJECT, self.get_export_dir())
103-
failed_job_log_file = logging_utils.get_error_log_file(
104-
wmconstants.WM_EXPORT, wmconstants.JOB_OBJECT, self.get_export_dir()
105-
)
106-
failed_acl_log_file = logging_utils.get_error_log_file(
103+
acl_error_logger = logging_utils.get_error_logger(
107104
wmconstants.WM_EXPORT, wmconstants.JOB_ACL_OBJECT, self.get_export_dir()
108105
)
109106
# pinned by cluster_user is a flag per cluster
@@ -113,10 +110,7 @@ def log_job_configs(self, users_list=None, groups_list = None, log_file='jobs.lo
113110
jl = list(filter(lambda x: x.get('creator_user_name', '') in users_list, jl_full))
114111
else:
115112
jl = jl_full
116-
with open(jobs_log, "w") as log_fp, \
117-
open(acl_jobs_log, 'w') as acl_fp, \
118-
open(failed_job_log_file, "w") as failed_log_fp, \
119-
open(failed_acl_log_file, "w") as failed_acl_log_file:
113+
with open(jobs_log, "w") as log_fp, open(acl_jobs_log, 'w') as acl_fp:
120114
for x in jl:
121115
job_id = x['job_id']
122116
new_job_name = x['settings']['name'] + ':::' + str(job_id)
@@ -148,9 +142,11 @@ def log_job_configs(self, users_list=None, groups_list = None, log_file='jobs.lo
148142
acl_fp.write(json.dumps(job_perms) + '\n')
149143
else:
150144
# job_acl is malformed, the job is written to error output file
151-
logging.error(f"The following job id {job_id} has malformed permissions: {json.dumps(job_perms)}")
152-
failed_log_fp.write(json.dumps(x) + '\n')
153-
failed_acl_log_file.write(json.dumps(job_perms) + '\n')
145+
message = f"The following job id {job_id} has malformed permissions: {json.dumps(job_perms)}"
146+
logging.error(message)
147+
logging_utils.log_response_error(acl_error_logger, {
148+
'error': message
149+
})
154150

155151
def import_job_configs(self, log_file='jobs.log', acl_file='acl_jobs.log', job_map_file='job_id_map.log'):
156152
jobs_log = self.get_export_dir() + log_file

0 commit comments

Comments
 (0)