Skip to content
Snippets Groups Projects
Commit 13b1215a authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-2829: fixed parsing of df results. start task anyway if df fails.

parent f871b619
No related branches found
No related tags found
1 merge request!1326TMSS-2829
...@@ -80,44 +80,47 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler): ...@@ -80,44 +80,47 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler):
if subtask['state_value'] != 'queued': if subtask['state_value'] != 'queued':
return return
# determine destination host and root_dir try:
destination = subtask['specifications_doc']['destination'] # determine destination host and root_dir
dst_host = destination[:destination.find(':')] if ':' in destination else '' destination = subtask['specifications_doc']['destination']
dst_root_dir = '/'+destination.lstrip(dst_host + ':').split('/')[1] dst_host = destination[:destination.find(':')] if ':' in destination else ''
# strip unneeded localhost to prevent unneeded ssh calls dst_root_dir = '/'+destination.lstrip(dst_host + ':').split('/')[1]
dst_host = dst_host.lstrip('localhost:').lstrip('127.0.0.1:') # strip unneeded localhost to prevent unneeded ssh calls
dst_host = dst_host.lstrip('localhost:').lstrip('127.0.0.1:')
df_cmd = ['df', dst_root_dir]
if dst_host: df_cmd = ['df', dst_root_dir]
df_cmd = wrap_command_in_ssh_call(df_cmd, dst_host) if dst_host:
df_cmd = wrap_command_in_ssh_call(df_cmd, dst_host)
logger.info("checking free disk space for copy-subtask id=%s, executing: %s", subtask['id'], ' '.join(df_cmd))
logger.info("checking free disk space for copy-subtask id=%s, executing: %s", subtask['id'], ' '.join(df_cmd))
# run df cmd, and parse output for total free disk space
df_result = check_output_returning_strings(df_cmd) # run df cmd, and parse output for total free disk space
logger.info(str(df_result)) df_result = check_output_returning_strings(df_cmd)
df_result_line = df_result.splitlines()[-1] df_result_line = df_result.splitlines()[-1]
logger.info(str(df_result_line)) df_result_line_parts = df_result_line.split()
df_result_line_parts = df_result_line.split(' ') df_bytes = int(df_result_line_parts[3])
logger.info(str(df_result_line_parts)) input_dp_sizes = self.tmss_client.get_url_as_json_object(subtask['url'].rstrip('/')+'/input_dataproducts?fields=size')
df_bytes = int(df_result_line_parts[3]) total_size = sum(x['size'] for x in input_dp_sizes)
input_dp_sizes = self.tmss_client.get_url_as_json_object(subtask['url'].rstrip('/')+'/input_dataproducts?fields=size')
total_size = sum(x['size'] for x in input_dp_sizes) if df_bytes > total_size:
logger.info("enough free disk space available for copy-subtask id=%s destination=%s df=%d needed=%d", subtask['id'], destination, df_bytes, total_size)
if df_bytes > total_size:
logger.info("enough free disk space available for copy-subtask id=%s destination=%s df=%d needed=%d", subtask['id'], destination, df_bytes, total_size) # clear previously set "not enough free disk space available" error_reason if set
if subtask.get('error_reason'):
# clear previously set "not enough free disk space available" error_reason if set self.tmss_client.do_request_and_get_result_as_string('PATCH', subtask['url'], {'error_reason': None})
if subtask.get('error_reason'):
self.tmss_client.do_request_and_get_result_as_string('PATCH', subtask['url'], {'error_reason': None}) # run it
self.run_copy_subtask(subtask)
# run it else:
self.run_copy_subtask(subtask) msg = "not enough free disk space available to start copy-subtask id=%s df=%d needed=%d" % (subtask['id'], df_bytes, total_size)
else: logger.info(msg)
msg = "not enough free disk space available to start copy-subtask id=%s df=%d needed=%d" % (subtask['id'], df_bytes, total_size) self.tmss_client.do_request_and_get_result_as_string('PATCH', subtask['url'], {'error_reason': msg})
logger.info(msg) except Exception as e:
self.tmss_client.do_request_and_get_result_as_string('PATCH', subtask['url'], {'error_reason': msg}) logger.exception(str(e))
# try to run it anyway, maybe it fails on not enough disk space.
# if it fails while running, then it results in an error status, and the user can take appropriate action.
self.run_copy_subtask(subtask)
def run_copy_subtask(self, subtask): def run_copy_subtask(self, subtask):
if subtask['subtask_type'] != 'copy': if subtask['subtask_type'] != 'copy':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment