Commit 50a7e1cb authored by lavado's avatar lavado
Browse files

Merge branch 'hackfest9' into 'master'

Fix magmagw: race condition when orch not ready yet

See merge request !22
parents 396ee6d7 45ba2068
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -173,11 +173,20 @@ class SimpleHAProxyCharm(CharmBase):
            orch_ip = event.params["orch_ip"]
            orch_net = event.params["orch_net"]
            proxy = self.get_ssh_proxy()

            attempt = 0
            while attempt < 50:
                try:
                    stdout, stderr = proxy.run(
                        "/home/magma/addnet.py --orch_ip {} --orch_net {}".format(
                            orch_ip, orch_net
                        )
                    )
                    break
                except subprocess.CalledProcessError:
                    attempt += 1
                    import time
                    time.sleep(5)
            event.set_results({"output": stdout, "stderr": stderr})
        else:
            event.fail("Unit is not leader")