Fix race condition in recreate containers
Container might have stopped between checking `is_running` and calling `stop()`, which then threw an exception. Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This commit is contained in:
parent
e117a7822d
commit
b573b87a92
2 changed files with 27 additions and 7 deletions
|
|
@ -177,8 +177,15 @@ class Service(object):
|
|||
return tuples
|
||||
|
||||
def recreate_container(self, container, **override_options):
|
||||
if container.is_running:
|
||||
try:
|
||||
container.stop(timeout=1)
|
||||
except APIError as e:
|
||||
if (e.response.status_code == 500
|
||||
and e.explanation
|
||||
and 'no such process' in str(e.explanation)):
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
intermediate_container = Container.create(
|
||||
self.client,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue