Skip to content

Commit 4b1e6b8

Browse files
author
Matthew Fisher
committed
Merge pull request #1711 from bacongobbler/wait-for-container
fix(scheduler): initially wait for container to start
2 parents 23d7e30 + c273b27 commit 4b1e6b8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

controller/scheduler/coreos.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def start(self, name, use_announcer=True):
126126

127127
if use_announcer:
128128
self._start_announcer(name, env)
129-
self._wait_for_announcer(name, env)
129+
self._wait_for_container(name, env)
130130
else:
131131
self._log_skipped_announcer('start', name)
132132

@@ -145,10 +145,20 @@ def _start_announcer(self, name, env):
145145
'fleetctl.sh start -no-block {name}-announce.service'.format(**locals()),
146146
shell=True, env=env)
147147

148-
def _wait_for_announcer(self, name, env):
148+
def _wait_for_container(self, name, env):
149149
status = None
150150
# we bump to 20 minutes here to match the timeout on the router and in the app unit files
151151
for _ in range(1200):
152+
# check if the main container's running
153+
status = subprocess.check_output(
154+
"fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}.service | awk '{{print $2}}'".format(**locals()), # noqa
155+
shell=True, env=env).strip('\n')
156+
if status == 'failed':
157+
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
152162
status = subprocess.check_output(
153163
"fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}-announce.service | awk '{{print $2}}'".format(**locals()), # noqa
154164
shell=True, env=env).strip('\n')

0 commit comments

Comments
 (0)