From 0378f386b198c4596682cc1f78ca7b4839d70bfa Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Thu, 5 Sep 2019 10:40:43 +1200 Subject: [PATCH] Add timeout for juju controllers refresh If you have a dead controller, which is already deleted but still has a local record in juju, it will cause a few problems without hints: 1. juju destroy-model will freeze forever 2. juju kill-model will fail with unuseful message 3. juju controllers --refresh will freeze forever The only way to fix so far is `juju unregister`. A related bug has been reported: https://bugs.launchpad.net/juju-core/+bug/1593506 `functest-prepare` will also freeze forever because of 3, without any message. To avoid wasting time on waiting, add timeout and help message for people to find the problem earlier. Signed-off-by: Joe Guo --- zaza/controller.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zaza/controller.py b/zaza/controller.py index a13a01b9c..cd28c3b71 100644 --- a/zaza/controller.py +++ b/zaza/controller.py @@ -33,7 +33,13 @@ async def async_add_model(model_name, config=None): """ # Tactical fix until https://github.com/juju/python-libjuju/issues/333 # is resolved - subprocess.check_call(['juju', 'list-controllers', '--refresh']) + + # if you have a dead controller, this cmd will wait forever. + # add timeout to avoid waiting. + # use `juju unregister` to remove your dead controller and try again + # related bug: https://bugs.launchpad.net/juju-core/+bug/1593506 + subprocess.check_call(['juju', 'list-controllers', '--refresh'], + timeout=60) model_cmd = ['juju', 'add-model', '--no-switch'] if config: with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml') as fp: