diff --git a/coordinator/ProcessorServer.py b/coordinator/ProcessorServer.py index cca3e763450628dbb2b1e876bbebbf71f2896bcc..c07349d5519adbddd729bc123c68ccd375e19a8f 100644 --- a/coordinator/ProcessorServer.py +++ b/coordinator/ProcessorServer.py @@ -37,17 +37,28 @@ def process_pre_job_server_download(input_args: dict): file_path = Template(config[component]['ServerPathTemplate']).substitute(**config) file_name = Template(config[component]['InputFileTemplate']).substitute(**config) - logger.info(f"Checking for existence of {file_path}/{file_name}.tar.gz") + file_path_full = f"{file_path}/{file_name}.tar.gz" + logger.info(f"Checking for existence of {file_path_full}") timenow = datetime.datetime.now(tz=datetime.timezone.utc).time() - cmd_ssh = ["ssh","-i",config['ServerKey'],"-o","StrictHostKeyChecking=no",config['ServerName'],f"test -f {file_path}/{file_name}.tar.gz"] + # test whether the file exists (if not, returns error code 1) + # and test whether the tar file is complete (if not, error code is 2) + cmd_ssh = [ + "ssh", + "-i", + config['ServerKey'], + "-o", + "StrictHostKeyChecking=no", + config['ServerName'], + f"test -f {file_path_full} && tar -tzf {file_path_full} >/dev/null"] + description_short = 'subprocess_ssh' - description_long = f"Checking for existence of {file_path}/{file_name}.tar.gz" + description_long = f"Checking for existence of {file_path_full}" status = subprocess_and_log(cmd_ssh,description_short,description_long,check=False) - if status.returncode == 1: + if status.returncode > 0: # a time check in UTC. If it's late, raise warning, if very late, raise error