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

Fixes lp#1751849: Registration token used up, users needs guidance to resolve. #8435

Merged
merged 1 commit into from Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/juju/controller/register.go
Expand Up @@ -270,6 +270,12 @@ func (c *registerCommand) nonPublicControllerDetails(ctx *cmd.Context, registrat
}
resp, err := c.secretKeyLogin(registrationParams.controllerAddrs, req, controllerName)
if err != nil {
// If we got here and got an error, the registration token supplied
// will be expired.
// Log the error as it will be useful for debugging, but give user a
// suggestion for the way forward instead of error details.
logger.Infof("while validating secret key: %v", err)
err = errors.Errorf("Provided registration token may have been expired.\nA controller administrator must reset your user to issue a new token.\nSee %q for more information.", "juju help change-user-password")
return errRet(errors.Trace(err))
}

Expand Down
12 changes: 10 additions & 2 deletions cmd/juju/controller/register_test.go
Expand Up @@ -407,7 +407,11 @@ Enter a name for this controller: »foo
defer prompter.CheckDone()
s.apiOpenError = errors.New("open failed")
err := s.run(c, prompter, registrationData)
c.Assert(err, gc.ErrorMatches, `open failed`)
c.Assert(c.GetTestLog(), gc.Matches, "(.|\n)*open failed(.|\n)*")
c.Assert(err, gc.ErrorMatches, `
Provided registration token may have been expired.
A controller administrator must reset your user to issue a new token.
See "juju help change-user-password" for more information.`[1:])
}

func (s *RegisterSuite) TestRegisterServerError(c *gc.C) {
Expand All @@ -434,7 +438,11 @@ Enter a name for this controller: »foo
SecretKey: mockSecretKey,
})
err = s.run(c, prompter, registrationData)
c.Assert(err, gc.ErrorMatches, "xyz")
c.Assert(c.GetTestLog(), gc.Matches, "(.|\n)* xyz(.|\n)*")
c.Assert(err, gc.ErrorMatches, `
Provided registration token may have been expired.
A controller administrator must reset your user to issue a new token.
See "juju help change-user-password" for more information.`[1:])

// Check that the controller hasn't been added.
_, err = s.store.ControllerByName("controller-name")
Expand Down