From 9dde89a60fa89f1ebff9961d6ec378432f4b6585 Mon Sep 17 00:00:00 2001
From: Stefano Alberto Russo <stefano.russo@gmail.com>
Date: Tue, 5 May 2020 01:27:00 +0200
Subject: [PATCH] Fixed bug in view log function for remote computing manager.

---
 .../rosetta/core_app/computing_managers.py    | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/services/webapp/code/rosetta/core_app/computing_managers.py b/services/webapp/code/rosetta/core_app/computing_managers.py
index 87f64d3..b198bf2 100644
--- a/services/webapp/code/rosetta/core_app/computing_managers.py
+++ b/services/webapp/code/rosetta/core_app/computing_managers.py
@@ -260,19 +260,20 @@ class RemoteComputingManager(ComputingManager):
 
 
     def _get_task_log(self, task, **kwargs):
-        # Get computing host
-        host = task.computing.get_conf_param('host')
-
-        # Get id_rsa
+        
+        # Get user keys
         if task.computing.require_user_keys:
             user_keys = Keys.objects.get(user=task.user, default=True)
-            id_rsa_file = user_keys.private_key_file
         else:
-            raise NotImplementedError('Remote with no keys not yet')
+            raise NotImplementedError('Remote tasks not requiring keys are not yet supported')
+
+        # Get computing host
+        host = task.computing.get_conf_param('master')
+        user = task.computing.get_conf_param('user')
+
+        # Stop the task remotely
+        view_log_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {}@{} \'/bin/bash -c "cat /tmp/{}.log"\''.format(user_keys.private_key_file, user, host, task.uuid)
 
-        # View the Singularity container log
-        view_log_command = 'ssh -i {} -4 -o StrictHostKeyChecking=no {} \'/bin/bash -c "cat /tmp/{}.log"\''.format(id_rsa_file, host, task.uuid)
-        logger.debug(view_log_command)
         out = os_shell(view_log_command, capture=True)
         if out.exit_code != 0:
             raise Exception(out.stderr)
-- 
GitLab