From fd079a640b7dda0067084316bcf65beaf9ac753b Mon Sep 17 00:00:00 2001 From: zackramjan Date: Fri, 20 Mar 2020 14:28:57 -0400 Subject: [PATCH 1/3] added full path to sudo rclone call due to user PATHs not including rlcone in all cases --- src/backend/api/utils/rclone_connection.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/api/utils/rclone_connection.py b/src/backend/api/utils/rclone_connection.py index 9c16fe50..667d2b88 100644 --- a/src/backend/api/utils/rclone_connection.py +++ b/src/backend/api/utils/rclone_connection.py @@ -39,7 +39,7 @@ def verify(self, data): 'sudo', '-E', '-u', user, - 'rclone', + '/usr/local/bin/rclone', 'lsjson', 'current:{}'.format(bucket), ] @@ -68,7 +68,7 @@ def ls(self, data, path): 'sudo', '-E', '-u', user, - 'rclone', + '/usr/local/bin/rclone', 'lsjson', 'current:{}'.format(path), ] @@ -94,7 +94,7 @@ def mkdir(self, data, path): 'sudo', '-E', '-u', user, - 'rclone', + '/usr/local/bin/rclone', 'touch', 'current:{}/.motuz_keep'.format(path), ] @@ -143,7 +143,7 @@ def copy(self, 'sudo', '-E', '-u', user, - 'rclone', + '/usr/local/bin/rclone', 'copyto', src, dst, @@ -203,7 +203,7 @@ def md5sum(self, 'sudo', '-E', '-u', user, - 'rclone', + '/usr/local/bin/rclone', 'md5sum', src, ] From fff551f28e4dc9a64bd8751c1ad61f4d17766149 Mon Sep 17 00:00:00 2001 From: zackramjan Date: Sat, 21 Mar 2020 21:37:29 -0400 Subject: [PATCH 2/3] added full path to sudo rclone (in two files) call due to user PATHs not including rlcone in all cases --- src/backend/api/utils/hashsum_job_queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/api/utils/hashsum_job_queue.py b/src/backend/api/utils/hashsum_job_queue.py index 214c6359..86c92508 100644 --- a/src/backend/api/utils/hashsum_job_queue.py +++ b/src/backend/api/utils/hashsum_job_queue.py @@ -122,7 +122,7 @@ def __execute_interactive(self, command, env, job_id, download): 'sudo', '-E', '-u', user, - 'rclone', + '/usr/local/bin/rclone', 'cat', 'src:{}'.format(os.path.join(os.path.dirname(base), file['Name'])), ] From 892252eb50acbd8135bf9df9872df5e4cfe6277b Mon Sep 17 00:00:00 2001 From: zackramjan Date: Mon, 18 Apr 2022 16:37:14 -0400 Subject: [PATCH 3/3] save task stdout and stderr to DB and persist across sessions --- src/backend/api/managers/copy_job_manager.py | 12 ++++++++++++ src/backend/api/tasks/celery_tasks.py | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/backend/api/managers/copy_job_manager.py b/src/backend/api/managers/copy_job_manager.py index 28d81b22..8c49f24b 100644 --- a/src/backend/api/managers/copy_job_manager.py +++ b/src/backend/api/managers/copy_job_manager.py @@ -75,6 +75,18 @@ def retrieve(id): else: logging.error("Rabbitmq closed the connection. Failing silently") + try: + textFromDB = copy_job.progress_error.split("|^|") + try: + copy_job.progress_text + except: + if len(textFromDB) > 0: + copy_job.progress_text = textFromDB[0] + if len(textFromDB) > 1: + copy_job.progress_error_text = textFromDB[1] + except: + logging.error("no task output found in DB. Failing silently") + return copy_job diff --git a/src/backend/api/tasks/celery_tasks.py b/src/backend/api/tasks/celery_tasks.py index b6de3c3f..25202fde 100644 --- a/src/backend/api/tasks/celery_tasks.py +++ b/src/backend/api/tasks/celery_tasks.py @@ -57,6 +57,9 @@ def copy_job(self, task_id=None): else: copy_job.progress_state = 'FAILED' + # save copy stdout and stderr to DB #ZR + output_text = connection.copy_text(task_id) + "|^|" + connection.copy_error_text(task_id) + copy_job.progress_error = output_text copy_job.progress_current = 100 copy_job.progress_execution_time = int(time.time() - start_time)