Skip to content

Commit 0308fd2

Browse files
committed
fix(controller): test that RC is available before accessing it
1 parent 3250dee commit 0308fd2

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

controller/scheduler/fleet.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ def run(self, name, image, entrypoint, command): # noqa
271271
tran = ssh.get_transport()
272272

273273
def _do_ssh(cmd):
274-
chan = tran.open_session()
275-
# get a pty so stdout/stderr look right
276-
chan.get_pty()
277-
out = chan.makefile()
278-
chan.exec_command(cmd)
279-
output = out.read()
280-
rc = chan.recv_exit_status()
281-
return rc, output
274+
with tran.open_session() as chan:
275+
chan.exec_command(cmd)
276+
while not chan.exit_status_ready():
277+
time.sleep(1)
278+
out = chan.makefile()
279+
output = out.read()
280+
rc = chan.recv_exit_status()
281+
return rc, output
282282

283283
# wait for container to launch
284284
# we loop indefinitely here, as we have no idea how long the docker pull will take

0 commit comments

Comments
 (0)