Skip to content

Commit 0cf4886

Browse files
author
Gabriel Monroy
committed
fix(scheduler): handle announcer timeouts to work around moby/moby#8022
1 parent 336d5f6 commit 0cf4886

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

controller/scheduler/coreos.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def start(self, name, use_announcer=True):
127127
if use_announcer:
128128
self._start_announcer(name, env)
129129
self._wait_for_container(name, env)
130+
self._wait_for_announcer(name, env)
130131
else:
131132
self._log_skipped_announcer('start', name)
132133

@@ -153,20 +154,30 @@ def _wait_for_container(self, name, env):
153154
status = subprocess.check_output(
154155
"fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}.service | awk '{{print $2}}'".format(**locals()), # noqa
155156
shell=True, env=env).strip('\n')
156-
if status == 'failed':
157+
if status == 'running':
158+
break
159+
elif status == 'failed':
157160
raise RuntimeError('Container failed to start')
158-
elif status != 'running':
159-
time.sleep(1)
160-
continue
161-
# wait for the announce service to come up as well
161+
time.sleep(1)
162+
else:
163+
raise RuntimeError('Container timeout on start')
164+
165+
def _wait_for_announcer(self, name, env):
166+
status = None
167+
# wait a bit for the announcer to come up, otherwise we may have hit
168+
# https://github.com/docker/docker/issues/8022
169+
for _ in range(30):
170+
# check if the main container's running
162171
status = subprocess.check_output(
163172
"fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}-announce.service | awk '{{print $2}}'".format(**locals()), # noqa
164173
shell=True, env=env).strip('\n')
165174
if status == 'running':
166175
break
176+
elif status == 'failed':
177+
raise RuntimeError('Announcer failed to start')
167178
time.sleep(1)
168179
else:
169-
raise RuntimeError('Container failed to start')
180+
raise RuntimeError('Announcer timeout on start')
170181

171182
def stop(self, name, use_announcer=True):
172183
"""

0 commit comments

Comments
 (0)