Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rosetta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ExaCT
Rosetta
Commits
35cdede9
Commit
35cdede9
authored
1 year ago
by
Stefano Alberto Russo
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue in checking task interface status on the connect view.
parent
15054114
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/webapp/code/rosetta/core_app/views.py
+31
-17
31 additions, 17 deletions
services/webapp/code/rosetta/core_app/views.py
with
31 additions
and
17 deletions
services/webapp/code/rosetta/core_app/views.py
+
31
−
17
View file @
35cdede9
...
@@ -1133,27 +1133,41 @@ def task_connect(request):
...
@@ -1133,27 +1133,41 @@ def task_connect(request):
# Ensure that the tunnel and proxy are set up
# Ensure that the tunnel and proxy are set up
setup_tunnel_and_proxy
(
task
)
setup_tunnel_and_proxy
(
task
)
# Set default interface status as unknown
task
.
interface_status
=
'
unknown
'
# Check if task interface is up
# Check if task interface is up
if
task
.
status
==
'
running
'
:
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
))
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
()
if
task
.
container
.
interface_protocol
.
startswith
(
'
http
'
):
try
:
try
:
s
.
settimeout
(
1
)
if
task
.
requires_tcp_tunnel
:
s
.
connect
((
'
127.0.0.1
'
,
task
.
tcp_tunnel_port
))
requests
.
get
(
'
{}://localhost:{}
'
.
format
(
task
.
container
.
interface_protocol
,
task
.
tcp_tunnel_port
),
timeout
=
3
)
# 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
'
else
:
else
:
logger
.
debug
(
'
task interface is answering
'
)
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
'
task
.
interface_status
=
'
running
'
finally
:
except
Exception
as
e
:
s
.
close
()
logger
.
debug
(
'
Could not connect to task interface ({})
'
.
format
(
e
))
else
:
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
=
{}
data
[
'
task
'
]
=
task
data
[
'
task
'
]
=
task
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment