Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout for juju controllers refresh #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion zaza/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +36 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice change, but there is a major fault in the original code, which is that there is a non-async subprocess.check_call(...) in an async function. This will stall the async loop which basically forces it to sync. This should be changed to use the asyncio equivalent.

model_cmd = ['juju', 'add-model', '--no-switch']
if config:
with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml') as fp:
Expand Down