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

TMSS-2829: fixed host/path parsing

parent 9e54ea52
Branches
No related tags found
No related merge requests found
...@@ -39,14 +39,16 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler): ...@@ -39,14 +39,16 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler):
def start_handling(self): def start_handling(self):
self.tmss_client.open() self.tmss_client.open()
super().start_handling()
def stop_handling(self): def stop_handling(self):
super().stop_handling()
self.tmss_client.close() self.tmss_client.close()
def before_receive_message(self): def before_receive_message(self):
# use 1-sec event loop to poll queued subtasks (rate limited at 30sec) # use 1-sec event loop to poll queued subtasks (rate limited at 60sec)
super().before_receive_message() super().before_receive_message()
if datetime.utcnow() - self._last_df_check_timestamp > timedelta(seconds=30): if datetime.utcnow() - self._last_df_check_timestamp > timedelta(seconds=60):
self._last_df_check_timestamp = datetime.utcnow() self._last_df_check_timestamp = datetime.utcnow()
self.check_and_run_queued_copy_subtask_if_enough_disk_space() self.check_and_run_queued_copy_subtask_if_enough_disk_space()
...@@ -84,9 +86,9 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler): ...@@ -84,9 +86,9 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler):
# determine destination host and root_dir # determine destination host and root_dir
destination = subtask['specifications_doc']['destination'] destination = subtask['specifications_doc']['destination']
dst_host = destination[:destination.find(':')] if ':' in destination else '' dst_host = destination[:destination.find(':')] if ':' in destination else ''
dst_root_dir = '/'+destination.lstrip(dst_host + ':').split('/')[1] dst_root_dir = '/'+destination.replace(dst_host + ':', '').split('/')[1]
# strip unneeded localhost to prevent unneeded ssh calls # remove unneeded localhost to prevent unneeded ssh calls
dst_host = dst_host.lstrip('localhost:').lstrip('127.0.0.1:') dst_host = dst_host.replace('localhost:','').replace('127.0.0.1:','')
df_cmd = ['df', dst_root_dir] df_cmd = ['df', dst_root_dir]
if dst_host: if dst_host:
...@@ -157,11 +159,11 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler): ...@@ -157,11 +159,11 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler):
# split in host & parent_dir_path # split in host & parent_dir_path
dst_host = output_dp_path[:output_dp_path.find(':')] if ':' in output_dp_path else '' dst_host = output_dp_path[:output_dp_path.find(':')] if ':' in output_dp_path else ''
dst_parent_dir_path = output_dp_path.lstrip(dst_host + ':').rstrip(input_dataproduct['filename']) dst_parent_dir_path = output_dp_path.replace(dst_host + ':','').replace(input_dataproduct['filename'],'')
# strip unneeded localhost to prevent under-the-hood ssh wrapping in rsync, and to prevent unneed ssh calls # replace unneeded localhost to prevent under-the-hood ssh wrapping in rsync, and to prevent unneed ssh calls
dst_host = dst_host.lstrip('localhost:').lstrip('127.0.0.1:') dst_host = dst_host.replace('localhost:','').replace('127.0.0.1:', '')
dst_parent_dir_path = dst_parent_dir_path.lstrip('localhost:').lstrip('127.0.0.1:') dst_parent_dir_path = dst_parent_dir_path.replace('localhost:','').replace('127.0.0.1:','')
if dst_parent_dir_path not in _created_dir_cache: if dst_parent_dir_path not in _created_dir_cache:
# create dst_parent_dir_path directories if needed, prepend them to the cmd # create dst_parent_dir_path directories if needed, prepend them to the cmd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment