better error msgs #6782

Merged
merged 2 commits into from Jan 10, 2017

Conversation

Projects
None yet
4 participants
Contributor

reedobrien commented Jan 8, 2017

Add annotations to error messages from shelling out so we get informative error
messages. It currently reports "exit 1". Also change a couple logging statments Debug as the
caller logs an error and they just duplicate the information noisily.

QA: (This currently fails on develop but when the network code @jameinel and @frobware are working on lands, it won't fail anymore.)

  1. Setup a maas
  2. go install github.com/juju/juju/...
  3. juju bootstrap vmaas21 kvm/purego --build-agent --constraints mem=2G
  4. juju add-machine
  5. juju add-machine --series trusty
  6. juju deploy mysql --to kvm:0
  7. juju deploy postgresql --to kvm:1 --series xenial
  8. juju deploy wordpress --to kvm:1
  9. juju deploy ubuntu --to kvm:0 --constraints mem=1G
    10 .juju add-relation wordpress mysql

Check the logs and ensure we don't have a bunch of duplicate failure messages and that there is reasonable information regarding the failure.
juju debug-log --level DEBUG --replay --include machine-1
juju debug-log --level DEBUG --replay --include machine-0

Cleanup: juju kill-controller kvm/purego -y

Make error messages more informative
Add annotations to error messages so that we get more informative error
message than "exit 1". Also change an Info message to a Debug as it's
caller logs it as an error.
Contributor

reedobrien commented Jan 8, 2017

!!build!!

container/kvm/kvm.go
- logger.Infof(err.Error())
+ // Logged as debug here because it is logged as an error in
+ // worker/provisioner.
+ logger.Debugf(err.Error())
@rogpeppe

rogpeppe Jan 9, 2017

Owner

There's no point in logging error messages that we return (especially when they're
less informative than the error that we're returning).

The appropriate place for logging errors is if we're discarding them.

@reedobrien

reedobrien Jan 9, 2017

Contributor

I agree. This was existing code. I just wanted to turn down the amount of logging of the same error.

Removed.

container/kvm/wrappedcmds_test.go
@@ -203,7 +203,7 @@ func (commandWrapperSuite) TestAutostartMachineFails(c *gc.C) {
container := NewTestContainer("aname", stub.Run, nil)
err := AutostartMachine(container)
c.Assert(stub.Calls(), jc.DeepEquals, []string{"virsh autostart aname"})
- c.Assert(err, gc.ErrorMatches, "Boom")
+ c.Check(err, gc.ErrorMatches, "failed to autostart domain \"aname\": Boom")
@rogpeppe

rogpeppe Jan 9, 2017

Owner

backquotes?

@reedobrien

reedobrien Jan 9, 2017

Contributor

I usually use backquotes. Not sure what I was thinking...well I do, but prolly not worth the story. Fixed.

worker/provisioner/kvm-broker.go
@@ -70,7 +70,7 @@ func (broker *kvmBroker) StartInstance(args environs.StartInstanceParams) (*envi
if err != nil {
// It's not fatal (yet) if we couldn't pre-allocate addresses for the
// container.
- logger.Warningf("failed to prepare container %q network config: %v", machineId, err)
+ logger.Debugf("failed to prepare container %q network config: %v", machineId, err)
@rogpeppe

rogpeppe Jan 9, 2017

Owner

It might not be fatal, but it seems like it warrants more than Debug...

@reedobrien

reedobrien Jan 9, 2017

Contributor

SEt back to info, though I'm hopeful that the new dynamic bridging stuff makes this go away.

Updates per #6872 changes to log levels
- Use backticks to escape quoting
- Don't log returned error
- Log unreturned non-error as Info
container/kvm/kvm.go
- logger.Infof(err.Error())
+ // Logged as debug here because it is logged as an error in
+ // worker/provisioner.
+ logger.Debugf(err.Error())
@rogpeppe

rogpeppe Jan 9, 2017

Owner

There's no point in logging error messages that we return (especially when they're
less informative than the error that we're returning).

The appropriate place for logging errors is if we're discarding them.

@reedobrien

reedobrien Jan 9, 2017

Contributor

I agree. This was existing code. I just wanted to turn down the amount of logging of the same error.

Removed.

container/kvm/wrappedcmds_test.go
@@ -203,7 +203,7 @@ func (commandWrapperSuite) TestAutostartMachineFails(c *gc.C) {
container := NewTestContainer("aname", stub.Run, nil)
err := AutostartMachine(container)
c.Assert(stub.Calls(), jc.DeepEquals, []string{"virsh autostart aname"})
- c.Assert(err, gc.ErrorMatches, "Boom")
+ c.Check(err, gc.ErrorMatches, "failed to autostart domain \"aname\": Boom")
@rogpeppe

rogpeppe Jan 9, 2017

Owner

backquotes?

@reedobrien

reedobrien Jan 9, 2017

Contributor

I usually use backquotes. Not sure what I was thinking...well I do, but prolly not worth the story. Fixed.

worker/provisioner/kvm-broker.go
@@ -70,7 +70,7 @@ func (broker *kvmBroker) StartInstance(args environs.StartInstanceParams) (*envi
if err != nil {
// It's not fatal (yet) if we couldn't pre-allocate addresses for the
// container.
- logger.Warningf("failed to prepare container %q network config: %v", machineId, err)
+ logger.Debugf("failed to prepare container %q network config: %v", machineId, err)
@rogpeppe

rogpeppe Jan 9, 2017

Owner

It might not be fatal, but it seems like it warrants more than Debug...

@reedobrien

reedobrien Jan 9, 2017

Contributor

SEt back to info, though I'm hopeful that the new dynamic bridging stuff makes this go away.

Contributor

reedobrien commented Jan 9, 2017

!!blah!!

Contributor

reedobrien commented Jan 9, 2017

$$merge$$

Contributor

jujubot commented Jan 9, 2017

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

Contributor

jujubot commented Jan 10, 2017

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

@jujubot jujubot merged commit 6d6cb1f into juju:develop Jan 10, 2017

1 check passed

github-check-merge-juju Built PR, ran unit tests, and tested LXD deploy. Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details

@reedobrien reedobrien deleted the reedobrien:b/better-error-msgs branch Jan 10, 2017

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