Skip to content
......@@ -14,8 +14,5 @@ __pycache__/
# Data
data*
# DB conf
services/webapp/db_conf.sh
# Compose
docker-compose.yml
......@@ -6,5 +6,5 @@ if [ ! -d ./services ]; then
exit 1
fi
rosetta/shell webapp "cd /opt/code && source /env.sh && source /db_conf.sh && BACKEND_LOG_LEVEL=ERROR python3 manage.py makemigrations"
rosetta/shell webapp "cd /opt/code && source /env.sh && BACKEND_LOG_LEVEL=ERROR python3 manage.py makemigrations"
......@@ -6,4 +6,4 @@ if [ ! -d ./services ]; then
exit 1
fi
rosetta/shell webapp "cd /opt/code && source /env.sh && source /db_conf.sh && BACKEND_LOG_LEVEL=ERROR python3 manage.py migrate"
rosetta/shell webapp "cd /opt/code && source /env.sh && BACKEND_LOG_LEVEL=ERROR python3 manage.py migrate"
......@@ -340,8 +340,8 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana
if container_engine == 'podman':
run_command += '--network=private --uts=private --userns=keep-id '
#run_command += '-d -t {}/{}:{}'.format(task.container.registry, task.container.image_name, task.container.image_tag)
run_command += '-h task-{} -t {}/{}:{}'.format(task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag)
run_command += '&>> /tmp/{}_data/task.log & echo \$!"\''.format(task.uuid)
run_command += '-h task-{} --name task-{} -t {}/{}:{}'.format(task.short_uuid, task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag)
run_command += '&>> /tmp/{}_data/task.log & echo $({} ps -a --filter name=task-{} --format="{{.ID}}")"\''.format(task.uuid, container_engine, task.short_uuid)
else:
raise NotImplementedError('Container engine {} not supported'.format(container_engine))
......
# Generated by Django 2.2.1 on 2023-10-07 10:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core_app', '0033_auto_20220410_1531'),
]
operations = [
migrations.AlterField(
model_name='task',
name='requires_tcp_tunnel',
field=models.BooleanField(verbose_name='Requires TCP tunnel'),
),
]
......@@ -286,7 +286,7 @@ class Task(models.Model):
interface_port = models.IntegerField('Interface port', blank=True, null=True)
# Task access
requires_tcp_tunnel = models.BooleanField('Requires a TCP tunnel')
requires_tcp_tunnel = models.BooleanField('Requires TCP tunnel')
tcp_tunnel_port = models.IntegerField('TCP tunnel port', blank=True, null=True)
requires_proxy = models.BooleanField('Requires proxy')
requires_proxy_auth = models.BooleanField('Requires proxy auth')
......
......@@ -1132,28 +1132,42 @@ def task_connect(request):
# Ensure that the tunnel and proxy are set up
setup_tunnel_and_proxy(task)
# Set default interface status as unknown
task.interface_status = 'unknown'
# Check if task interface is up
if task.status == 'running':
logger.debug('Checking if task interface is running by trying to establish connection via local tunnel on port "{}"'.format(task.tcp_tunnel_port))
s = socket.socket()
try:
s.settimeout(1)
s.connect(('127.0.0.1', task.tcp_tunnel_port))
# Not necessary, we just check that the container interfcae is up
#if not s.recv(10):
# logger.debug('No data read from socket')
# raise Exception('Could not read any data from socket')
except Exception:
logger.debug('Could not connect to task interface')
task.interface_status = 'unknown'
if task.container.interface_protocol.startswith('http'):
try:
if task.requires_tcp_tunnel:
requests.get('{}://localhost:{}'.format(task.container.interface_protocol, task.tcp_tunnel_port), timeout=3)
else:
requests.get('{}://{}:{}'.format(task.container.interface_protocol, task.interface_ip, task.interface_port), timeout=3)
logger.debug('Task interface is answering')
task.interface_status = 'running'
except Exception as e:
logger.debug('Could not connect to task interface ({})'.format(e))
else:
logger.debug('task interface is answering')
task.interface_status = 'running'
finally:
s.close()
else:
task.interface_status = 'unknown'
pass
# # TODO: the following raises a TimeoutError even if the connection is active and with requests work. Why?
# with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
# s.settimeout(3)
# try:
# s.connect(('localhost', task.tcp_tunnel_port))
# if not s.recv(10):
# logger.debug('No data read from socket')
# raise Exception('Could not read any data from socket')
# except Exception as e:
# logger.debug('Could not connect to task interface via socket ({})'.format(e))
# task.interface_status = 'unknown'
# else:
# logger.debug('Task interface is answering via socket')
# task.interface_status = 'running'
data ={}
data['task'] = task
......