Description of change
Previous behavior of environment variables had produces surprising for user results.
Juju used $JUJU_CONTROLLER environment variable for controller level commands and not take $JUJU_MODEL value into consideration, even if the controller was supplied there in the form of <controller name>:<model name>.
At the same time, model level commands completely ignored $JUJU_CONTROLLER environment variable even if it was set.
This changes this behavior - current controller, whenever needed i.e. irrespective of the command level, is determined by looking at $JUJU_MODEL env var first, then $JUJU_CONTROLLER and lastly by the last outcome of running 'juju switch'.
The implicit fix here is also that if env var points to the controller that this client is not aware of (for example, 'juju controllers --refresh' needs to be run) Juju will now fail earlier.
In a follow-up PR, I'll be checking whether we always use $JUJU_MODEL correctly to determine current model. The logic will be similar.
QA steps
- bootstrap several controllers
- run 'juju switch' to switch to one of them
- set $JUJU_CONTROLLER to point to a different controller
- all subesquent commands should be running against the controller set by env var
Repeat the same by specifying different controller in $JUJU_MODEL via : format. All coomands should run against the controller specified in $JUJU_MODEL.
Bug reference
https://bugs.launchpad.net/juju/+bug/1786140 https://bugs.launchpad.net/juju/+bug/1813079
该提问来源于开源项目:juju/juju