Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
main
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Simone Rossi
main
Commits
7386dca3
Commit
7386dca3
authored
Dec 12, 2016
by
Daniele Venzano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Retry terminating containers if Swarm decides to time-out
parent
fc6dace7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
zoe_lib/swarm_client.py
zoe_lib/swarm_client.py
+26
-10
No files found.
zoe_lib/swarm_client.py
View file @
7386dca3
...
...
@@ -297,16 +297,32 @@ class SwarmClient:
:type delete: bool
:return: None
"""
if
delete
:
try
:
self
.
cli
.
remove_container
(
docker_id
,
force
=
True
)
except
docker
.
errors
.
NotFound
:
log
.
warning
(
"cannot remove a non-existent service"
)
else
:
try
:
self
.
cli
.
kill
(
docker_id
)
except
docker
.
errors
.
NotFound
:
log
.
warning
(
"cannot remove a non-existent service"
)
retries
=
5
while
retries
>
0
:
if
delete
:
try
:
self
.
cli
.
remove_container
(
docker_id
,
force
=
True
)
break
except
docker
.
errors
.
NotFound
:
log
.
warning
(
"cannot remove a non-existent service"
)
break
except
requests
.
exceptions
.
ReadTimeout
:
log
.
error
(
"Read timeout trying to delete a container"
)
retries
-=
1
continue
else
:
try
:
self
.
cli
.
kill
(
docker_id
)
break
except
docker
.
errors
.
NotFound
:
log
.
warning
(
"cannot remove a non-existent service"
)
break
except
requests
.
exceptions
.
ReadTimeout
:
log
.
error
(
"Read timeout trying to delete a container"
)
retries
-=
1
continue
if
retries
==
0
:
log
.
error
(
"Giving up trying to terminate container {}"
.
format
(
docker_id
))
def
event_listener
(
self
,
callback
:
Callable
[[
str
],
bool
])
->
None
:
"""An infinite loop that listens for events from Swarm."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment