Add --no-switch to juju bootstrap and add-model #7237

Merged
merged 3 commits into from Apr 24, 2017

Conversation

Projects
None yet
5 participants
Contributor

mjs commented Apr 13, 2017

Description of change

When performing operations in a script or in parallel the automatic switching to new controllers and models can lead to surprises and unwanted actions. juju bootstrap and juju add-model now take a -S / --no-switch flag to suppress this behaviour.

QA steps

# bootstrap with --no-switch works but doesn't select new controller
$ juju bootstrap dev devx --no-switch
Creating Juju controller "devx" on dev
...
Initial model "default" added.
$ juju switch
dev:admin/k3

# conventional bootstrap works as before
$ juju bootstrap dev devy            
Creating Juju controller "devy" on dev
...
Initial model "default" added.
$ juju switch
devy:admin/default

# add-model with --no-switch works but doesn't select the new model
$ juju add-model --no-switch frog
Using credential 'localhost' cached in controller
Added 'frog' model with credential 'localhost' for user 'admin'
$ juju switch
devy:admin/default

# conventional add-model works as before
$ juju add-model dog
Using credential 'localhost' cached in controller
Added 'dog' model with credential 'localhost' for user 'admin'
$ juju switch
devy:admin/dog

Documentation changes

Perhaps worth mentioning but this is fairly minor.

Bug reference

https://bugs.launchpad.net/juju/+bug/1618234

@mjs mjs changed the base branch from staging to develop Apr 13, 2017

f.BoolVar(&c.showClouds, "clouds", false, "Print the available clouds which can be used to bootstrap a Juju environment")
f.StringVar(&c.showRegionsForCloud, "regions", "", "Print the available regions for the specified cloud")
+ f.BoolVar(&c.noGUI, "no-gui", false, "Do not install the Juju GUI in the controller when bootstrapping")
+ f.BoolVar(&c.noSwitch, "S", false, "Do not switch to the newly created controller")
@jameinel

jameinel Apr 13, 2017

Owner

I'm not sure that we want -S as a short variable, it doesn't feel like this would be used enough.

Also, IMO, if you are going to have "no-foo" then you should also have "foo" so that any sort of change-to-the-default can always be done compatibly in the future.

@mjs

mjs Apr 13, 2017

Contributor

As per IRC, I'll canvass some opinions on this. If we're going to do --switch (default to true) then I'd prefer to not have a --no-switch. It seems weird to me to have to competing flags.

Then people would do --switch=false if they don't want switching.

@cmars

cmars Apr 14, 2017

Owner

I will use the heck out of this feature, because I automate Juju with scripts. I like -S quite a bit.

Owner

jameinel commented Apr 14, 2017

Owner

cmars commented Apr 14, 2017

@jameinel I disagree. I think a capitalized short -S flag, and a --no-switch long flag fit the existing idiom in the Juju CLI really well, for example:

-B, --no-browser-login  (= false)
    Do not use web browser for authentication

I'd rather be consistent than anything else.

Contributor

mjs commented Apr 21, 2017

Given that various --no-<something> switches already exist on juju bootstrap and elsewhere, I'm going to leave this as-is. It's unfortunate and unconventional that gnuflag takes an value for boolean command line flags.

Contributor

mjs commented Apr 21, 2017

$$merge$$

Contributor

jujubot commented Apr 21, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Apr 21, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10712

Owner

nskaggs commented Apr 21, 2017

!!build!!

Owner

nskaggs commented Apr 21, 2017

!!build!!

Contributor

mjs commented Apr 22, 2017

Looks like the changes are now incompatible with the current develop branch. I'll fix on Monday.

mjs added some commits Apr 13, 2017

cmd/juju/commands: Add --no-switch to bootstrap
Adding --no-switch causes `juju bootstrap` to *not* switch the client
over to the newly created controller.
cmd/juju/controller: Add --no-switch to add-model
-S / --no-switch prevents switching to the newly created model (as per
 bootstrap).
Contributor

mjs commented Apr 24, 2017

$$merge$$

Contributor

jujubot commented Apr 24, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Apr 24, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10729

Contributor

mjs commented Apr 24, 2017

$$vsphere-flakiness$$

Contributor

jujubot commented Apr 24, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Apr 24, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10732

Contributor

mjs commented Apr 24, 2017

$$merge$$

Contributor

jujubot commented Apr 24, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Apr 24, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10738

Contributor

mjs commented Apr 24, 2017

$$mongodb-on-windows$$

Contributor

jujubot commented Apr 24, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 433a21b into juju:develop Apr 24, 2017

@mjs mjs deleted the mjs:1618234-no-switch branch Apr 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment