From 2eca1ca077cceb64a912dc7b9f4f1619d75779c1 Mon Sep 17 00:00:00 2001 From: Vincent Brubaker-Gianakos Date: Fri, 5 Oct 2018 14:01:29 -0700 Subject: [PATCH] Await SSH tunnel init using docker exec + exit code Allows docker-push-ssh to be called inside of a docker container and check the tunnel status through docker inversion of control (by mounting the docker socket in the calling container). --- docker_push_ssh/cli.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docker_push_ssh/cli.py b/docker_push_ssh/cli.py index e33c1d3..63caaad 100644 --- a/docker_push_ssh/cli.py +++ b/docker_push_ssh/cli.py @@ -37,12 +37,16 @@ def waitForSshTunnelInit(retries=20, delay=1.0): for _ in range(retries): time.sleep(delay) - try: - response = urllib2.urlopen("http://localhost:5000/v2/", timeout=5) - except (socket.error, urllib2.URLError): - continue - - if response.getcode() == 200: + sshCheckCommandResult = Command("docker", [ + "exec", + "docker-push-ssh-tunnel", + "wget", + "-O", "/dev/null", + "-q", + "http://localhost:5000/v2" + ]).environment_dict(os.environ).execute() + + if not sshCheckCommandResult.failed(): return True return False