fix up error handling when no current controller #6306

Merged
merged 1 commit into from Sep 22, 2016

Conversation

Projects
None yet
3 participants
Contributor

natefinch commented Sep 22, 2016

fixes https://bugs.launchpad.net/juju/+bug/1618998
list-models should point out list-controllers command in error message

QA:
Edit ~/.local/share/juju/controllers.yaml to remove the value for current-controller
(it's at the bottom). Then run juju status and juju models. You should get nice
error messages that tell you how to get out of the situation. Also try changing
current-controller to a controller name that doesn't exist. It should behave the
same as not having a current controller.

+ context, err := s.runListControllers(c)
+ c.Assert(err, jc.ErrorIsNil)
+ c.Assert(testing.Stdout(context), gc.Equals, "")
+ c.Assert(testing.Stderr(context), gc.Equals, modelcmd.ErrNoControllersDefined.Error())
@kat-co

kat-co Sep 22, 2016

Contributor

These last two could be Check.

@natefinch

natefinch Sep 22, 2016

Contributor

Done.

-Please either create your own new controller using "juju bootstrap" or
-connect to another controller that you have been given access to using "juju register".
+Please either create a new controller using "juju bootstrap" or connect to
+another controller that you have been given access to using "juju register".
`)
@kat-co

kat-co Sep 22, 2016

Contributor

I'm pretty sure we shouldn't try and fix this here, but we should define error messages as simple strings with no newlines, and the view on the error should be controlled when its output.

@natefinch

natefinch Sep 22, 2016

Contributor

I know .... I started to do that, but it was going to be too complicated of a change, when all that was really asked for was for the text to be tweaked.

cmd/modelcmd/controller.go
+ if !errors.IsNotFound(err) {
+ return err
+ }
+ controllers, err := store.AllControllers()
@kat-co

kat-co Sep 22, 2016

Contributor

Does this do any network access?

@natefinch

natefinch Sep 22, 2016

Contributor

Nope, it reads your controllers.yaml. Disk access, while not ideal, still fairly reliable.

cmd/modelcmd/controller.go
+ if len(controllers) == 0 {
+ return ErrNoControllersDefined
+ }
+ return ErrNoCurrentController
}
@kat-co

kat-co Sep 22, 2016

Contributor

I don't think we should be discarding the error passed in. Please either mask it or annotate it.

@natefinch

natefinch Sep 22, 2016

Contributor

Looks like Wrap has the right behavior - change the message and the cause, but keep the stack

Contributor

natefinch commented Sep 22, 2016

$$merge$$

Contributor

jujubot commented Sep 22, 2016

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

jujubot added a commit that referenced this pull request Sep 22, 2016

Merge pull request #6307 from natefinch/fix-no-controller
fix up error handling when no current controller

fixes https://bugs.launchpad.net/juju/+bug/1618998
list-models should point out list-controllers command in error message

copy of #6306

@jujubot jujubot merged commit f30c18a into juju:master Sep 22, 2016

1 check failed

github-check-merge-juju Built PR, ran unit tests, and tested LXD deploy.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment