Skip to content
GitLab
Explore
Sign in
ExaCT
Rosetta
Compare revisions
150541143717335ccad4e589690a1460edcc47c0 to d9d434f97acab997e7d711f6e61f1cd84df95976
Commits on Source (3)
Fixed issue in checking task interface status on the connect view.
· 35cdede9
Stefano Alberto Russo
authored
Oct 07, 2023
35cdede9
Minor fixes and clenaup.
· 9afed027
Stefano Alberto Russo
authored
Oct 07, 2023
9afed027
Fixed bug in storing the container id for standalone computing resources unsing Docker or Podman.
· d9d434f9
Stefano Alberto Russo
authored
Oct 07, 2023
d9d434f9
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
d9d434f9
...
...
@@ -14,8 +14,5 @@ __pycache__/
# Data
data*
# DB conf
services/webapp/db_conf.sh
# Compose
docker-compose.yml
rosetta/makemigrations
View file @
d9d434f9
...
...
@@ -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"
rosetta/migrate
View file @
d9d434f9
...
...
@@ -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"
services/webapp/code/rosetta/core_app/computing_managers.py
View file @
d9d434f9
...
...
@@ -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
))
...
...
services/webapp/code/rosetta/core_app/migrations/0034_auto_20231007_1052.py
0 → 100644
View file @
d9d434f9
# 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
'
),
),
]
services/webapp/code/rosetta/core_app/models.py
View file @
d9d434f9
...
...
@@ -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
'
)
...
...
services/webapp/code/rosetta/core_app/views.py
View file @
d9d434f9
...
...
@@ -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
...
...