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
226e7bc1
Commit
226e7bc1
authored
3 months ago
by
Stefano Alberto Russo
Browse files
Options
Downloads
Patches
Plain Diff
Added some tolerance for tunnel creation and a simple retry logic in the task connect view.
parent
7b06070a
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
+20
-3
20 additions, 3 deletions
services/webapp/code/rosetta/core_app/views.py
with
20 additions
and
3 deletions
services/webapp/code/rosetta/core_app/views.py
+
20
−
3
View file @
226e7bc1
...
@@ -6,6 +6,7 @@ import requests
...
@@ -6,6 +6,7 @@ import requests
import
socket
import
socket
import
subprocess
import
subprocess
import
base64
import
base64
import
time
import
datetime
import
datetime
from
django.conf
import
settings
from
django.conf
import
settings
from
django.shortcuts
import
render
from
django.shortcuts
import
render
...
@@ -1151,11 +1152,27 @@ def task_connect(request):
...
@@ -1151,11 +1152,27 @@ def task_connect(request):
if
task
.
container
.
interface_protocol
.
startswith
(
'
http
'
):
if
task
.
container
.
interface_protocol
.
startswith
(
'
http
'
):
try
:
try
:
if
task
.
requires_tcp_tunnel
:
if
task
.
requires_tcp_tunnel
:
# Check three times, as there might be some delay in establishing the tunnel
# in background in the above setup_tunnel_and_proxy() call
attempts
=
0
while
True
:
try
:
requests
.
get
(
'
{}://localhost:{}
'
.
format
(
task
.
container
.
interface_protocol
,
task
.
tcp_tunnel_port
),
timeout
=
3
)
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
'
)
logger
.
debug
(
'
Task interface is answering
'
)
task
.
interface_status
=
'
running
'
task
.
interface_status
=
'
running
'
except
:
if
attempts
>
2
:
logger
.
debug
(
'
Too many attempts, giving up
'
)
raise
else
:
sleep_time
=
attempts
+
1
logger
.
debug
(
'
Task interface not answering, retrying ({}s)...
'
.
format
(
sleep_time
))
attempts
+=
1
time
.
sleep
(
sleep_time
)
else
:
break
else
:
requests
.
get
(
'
{}://{}:{}
'
.
format
(
task
.
container
.
interface_protocol
,
task
.
interface_ip
,
task
.
interface_port
),
timeout
=
3
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
debug
(
'
Could not connect to task interface ({})
'
.
format
(
e
))
logger
.
debug
(
'
Could not connect to task interface ({})
'
.
format
(
e
))
...
...
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