In the up and coming 2.9 release there will be a new Juju plugin;
wait-for plugin is the start of a standardising step for waiting for a given entity to reach a goal state.
wait-for command aims to address the one key concern that other predecessors struggle with; performance. The
wait-for command uses the
AllWatcher API instead of the
Status API. Unfortunately there is a long running issue that means that requesting the full status from Juju creates a lot of queries to the database and can cause a dramatic slowdown. If you’re only concerned with one application or one unit, this seems very wasteful.
wait-for command uses the same principal as the model-cache and pylibjuju, by listening to the changes from the AllWatcher we can create a view of the world as it happens.
wait-for command currently supports the following entities (others are being added):
As long as there is a bootstrapped controller, you can run the
wait-for command before or after you apply the changes to Juju, either way doesn’t matter.
juju deploy mysql juju wait-for application mysql --query='status=="active"'
Targeting the controller or other models without switching can be done in the normal Juju standardised way via the
juju wait-for -m controller machine 0 --query='status=="started" && life=="alive"'
Timeout values are represented as signed sequence of decimal numbers with a unit suffix i.e.
juju wait-for application mysql --query='status=="active"` --timeout=10m
There are some more advanced queries that you can perform to ensure that your given entity meets its goal state.
Supported operators in the query are as follows:
<=numeric comparisons (will work with strings as well)
len function is a builtin function that allows you to perform a length check on the following types:
juju wait-for model -m controller controller --query='len(config) > 0 && config["agent-stream"] == "released"'
forEach function is a builtin function that allows the iteration of sub entities to ensure their goal state matches the query. The
forEach will only work for maps of entity scope types:
For example the following query waits for all applications to wait for the status to become active.
juju wait-for model default --query='forEach(applications, app => app.status == "active")'
juju wait-for model -m controller controller --query='len(print(config)) > 0 && config["agent-stream"] == "released"'
Last updated 24 days ago.