SLA term required error #7157

Merged
merged 1 commit into from Mar 28, 2017

Conversation

Projects
None yet
4 participants
Owner

cmars commented Mar 24, 2017

Description of change

Why is this change needed?

The current error message displayed when agreement to SLA terms is terrible, something like:
ERROR cannot get discharge from "http://10.232.205.30/terms": third party refused discharge: term agreement required:

This change consolidates "term agreement required" error handling so that the error message is handled consistently across several commands including juju sla.

QA steps

How do we verify that the change works?

juju sla essential on a new model without having agreed to the required SLA terms would produce a nice error message:
Declined: please agree to the following terms term/1. Try: "juju agree term/1"

No regressions in this existing error message for other affected commands: deploy, upgradecharm.

Contact @cmars for assistance with setup issues for end-to-end testing.

Documentation changes

Does it affect current user workflow? CLI? API?

Not really. It only changes a new command.

Bug reference

Does this change fix a bug? Please add a link to it.

N/A

Owner

cmars commented Mar 24, 2017

!!test!!

+
+// UserErr returns an error containing a user-friendly message describing how
+// to agree to required terms.
+func (e *TermsRequiredError) UserErr() error {
@howbazaar

howbazaar Mar 27, 2017

Owner

I would like to see some tests for this with one and multiple missing term agreements.

@mjs

mjs Mar 27, 2017

Contributor

+1

Thanks for tidying this up.

cmd/juju/application/deploy.go
- terms := strings.Join(err1.Terms, " ")
- return errors.Errorf(`Declined: please agree to the following terms %s. Try: "juju agree %s"`, terms, terms)
+ if termErr, ok := errors.Cause(err).(*common.TermsRequiredError); ok {
+ return termErr.UserErr()
@mjs

mjs Mar 27, 2017

Contributor

errors.Trace?

+// MaybeTermsAgreementError returns err as a *TermsAgreementError
+// if it has a "terms agreement required" error code, otherwise
+// it returns err unchanged.
+func MaybeTermsAgreementError(err error) error {
@mjs

mjs Mar 27, 2017

Contributor

This is funky enough to require some tests

+
+// UserErr returns an error containing a user-friendly message describing how
+// to agree to required terms.
+func (e *TermsRequiredError) UserErr() error {
@howbazaar

howbazaar Mar 27, 2017

Owner

I would like to see some tests for this with one and multiple missing term agreements.

@mjs

mjs Mar 27, 2017

Contributor

+1

cmd/juju/common/errors.go
+func (e *TermsRequiredError) UserErr() error {
+ terms := strings.Join(e.Terms, " ")
+ return errors.Wrap(e,
+ errors.Errorf(`Declined: please agree to the following terms %s. Try: "juju agree %s"`,
@mjs

mjs Mar 27, 2017

Contributor

Do you really need to spell out the terms twice? How about something like this:

Declined: some terms require agreement. Try: "juju agree %s"

?

@cmars

cmars Mar 27, 2017

Owner

+1, but I'll need to followup on this one as it might break some of our CI tests. I think it'll be fine. Done.

mjs approved these changes Mar 28, 2017

Thank you!

cmd/juju/common/errors_test.go
+)
+
+type errorsSuite struct {
+ testing.BaseSuite
@mjs

mjs Mar 28, 2017

Contributor

IsolationSuite is the preferred base suite these days

Owner

cmars commented Mar 28, 2017

$$merge$$

Contributor

jujubot commented Mar 28, 2017

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

Contributor

jujubot commented Mar 28, 2017

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

Improve UX of agreement to terms required for SLAs.
Consolidate "terms required" errors across commands that can require
agreement to terms.
Owner

cmars commented Mar 28, 2017

$$merge$$

Contributor

jujubot commented Mar 28, 2017

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

@jujubot jujubot merged commit 59e9a82 into juju:develop Mar 28, 2017

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