Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
fix(scheduler): handle announcer timeouts to work around moby/moby#8022
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Monroy committed Sep 13, 2014
1 parent 336d5f6 commit 0cf4886
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions controller/scheduler/coreos.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def start(self, name, use_announcer=True):
if use_announcer:
self._start_announcer(name, env)
self._wait_for_container(name, env)
self._wait_for_announcer(name, env)
else:
self._log_skipped_announcer('start', name)

Expand All @@ -153,20 +154,30 @@ def _wait_for_container(self, name, env):
status = subprocess.check_output(
"fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}.service | awk '{{print $2}}'".format(**locals()), # noqa
shell=True, env=env).strip('\n')
if status == 'failed':
if status == 'running':
break
elif status == 'failed':
raise RuntimeError('Container failed to start')
elif status != 'running':
time.sleep(1)
continue
# wait for the announce service to come up as well
time.sleep(1)
else:
raise RuntimeError('Container timeout on start')

def _wait_for_announcer(self, name, env):
status = None
# wait a bit for the announcer to come up, otherwise we may have hit
# https://github.com/docker/docker/issues/8022
for _ in range(30):
# check if the main container's running
status = subprocess.check_output(
"fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}-announce.service | awk '{{print $2}}'".format(**locals()), # noqa
shell=True, env=env).strip('\n')
if status == 'running':
break
elif status == 'failed':
raise RuntimeError('Announcer failed to start')
time.sleep(1)
else:
raise RuntimeError('Container failed to start')
raise RuntimeError('Announcer timeout on start')

def stop(self, name, use_announcer=True):
"""
Expand Down

0 comments on commit 0cf4886

Please sign in to comment.