From c366fbe01a0c95e89365efd7ccb92d0e3d072f44 Mon Sep 17 00:00:00 2001 From: Stefano Alberto Russo <stefano.russo@gmail.com> Date: Wed, 10 Apr 2024 13:38:36 +0200 Subject: [PATCH] Improved handling tunnel creation and removed the "connect" button for non-http(s) interface protocol containers. --- .../code/rosetta/core_app/computing_managers.py | 13 ++++++++++++- .../rosetta/core_app/templates/components/task.html | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/services/webapp/code/rosetta/core_app/computing_managers.py b/services/webapp/code/rosetta/core_app/computing_managers.py index 8894ad6..06a017f 100644 --- a/services/webapp/code/rosetta/core_app/computing_managers.py +++ b/services/webapp/code/rosetta/core_app/computing_managers.py @@ -1,6 +1,6 @@ import os from .models import TaskStatuses, KeyPair, Task, Storage -from .utils import os_shell, get_ssh_access_mode_credentials, sanitize_container_env_vars, booleanize +from .utils import os_shell, get_ssh_access_mode_credentials, sanitize_container_env_vars, booleanize, setup_tunnel_and_proxy from .exceptions import ErrorMessage, ConsistencyException from django.conf import settings @@ -179,6 +179,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): # Save task.save() + + # Setup the tunnel if using a custom protocol (otherwise it will get set up via the "connect" button) + if task.container.interface_protocol not in ['http', 'https']: + setup_tunnel_and_proxy(task) def _stop_task(self, task): @@ -382,6 +386,10 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana # Save task.save() + # Setup the tunnel if using a custom protocol (otherwise it will get set up via the "connect" button) + if task.container.interface_protocol not in ['http', 'https']: + setup_tunnel_and_proxy(task) + def _stop_task(self, task, **kwargs): @@ -585,6 +593,9 @@ class SlurmSSHClusterComputingManager(ClusterComputingManager, SSHComputingManag # Save task.save() + # Setup the tunnel if using a custom protocol (otherwise it will get set up via the "connect" button) + if task.container.interface_protocol not in ['http', 'https']: + setup_tunnel_and_proxy(task) def _stop_task(self, task, **kwargs): diff --git a/services/webapp/code/rosetta/core_app/templates/components/task.html b/services/webapp/code/rosetta/core_app/templates/components/task.html index c3ac7f0..6ed502b 100644 --- a/services/webapp/code/rosetta/core_app/templates/components/task.html +++ b/services/webapp/code/rosetta/core_app/templates/components/task.html @@ -46,6 +46,12 @@ <div style="margin-top:2px"> {% if task.status == "running" %} <b>Status:</b> <font color="green">running</font> + {% if task.interface_protocol == 'http' or task.interface_protocol == 'http' %} + {% else %} + @ port {{ task.tcp_tunnel_port }} + {% endif %} + + {% else %} <b>Status:</b> {{ task.status }} {% endif %} @@ -63,12 +69,14 @@ <!-- Connect --> {% if task.interface_port %} + {% if task.interface_protocol == 'http' or task.interface_protocol == 'http' %} {% if task.status == "running" %} <a href="/task_connect/?uuid={{task.uuid}}" class="btn btn-connect">Connect</a> {% else %} <a href="" class="btn btn-disabled">Connect</a> {% endif %} {% endif %} + {% endif %} <!-- View log --> {% if task.status == "running" %} -- GitLab