Poor error message during collect-metrics

Bug #1885677 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Low
Unassigned

Bug Description

When an charm tries to do something that isn't allowed during collect-metrics, we get a poor error message:
unit-uo-0: 11:05:22 DEBUG unit.unit-uo-0.collect-metrics ERROR not implemented for restricted context not implemented

not implemented for restricted context not implemented

a) is redundantly redundant
b) doesn't tell you *what* is not implemented

The specific code does:
var ErrRestrictedContext = errors.NotImplementedf("not implemented for restricted context")

...

func (*RestrictedContext) GetCharmState() (map[string]string, error) {
        return nil, ErrRestrictedContext
}

And all functions just return ErrRestrictedContext.

Given that NotImplemented already adds 'not implemented' as a suffix, these should be updated to something more like:

func restrictedContext(method string) error {
  return errors.NotImplementedf("in a restricted context %s is", method)
}

func (*RestrictedContext) GetCharmState() (map[string]string, error) {
        return nil, restrictedContext("GetCharmState")
}

Which would give an error of:
"in a restricted context GetCharmState is not implemented"

I'm not super happy about it (suggestions welcome), but it is hard for me to find a nice way if we force 'not implemented' to be at the end. Either way, we need to be telling them *what* isn't implemented, because otherwise it is very hard to track down why the call is failing.

Revision history for this message
John A Meinel (jameinel) wrote :

Another possibility would be to clean up the error in such a way that you get the actual command that was being run. In this case I was running "state-get" so having it say

state-get not implemented in a restricted context

would be my ideal message.

Note that other than knowing we are running collect-metrics, we don't seem to have a way to know that we are running in a restricted context. So if Juju changes to no longer run collect-metrics asynchronously, we'll want a way to know that it is safe to operate as normal.

Revision history for this message
Pen Gale (pengale) wrote :

Agree that the error should be clearer. Marking this in the list of things to sweep up w/ the next version of 2.8.

Changed in juju:
importance: Undecided → Medium
milestone: none → 2.8-next
Revision history for this message
Canonical Juju QA Bot (juju-qa-bot) wrote :

This bug has not been updated in 2 years, so we're marking it Low importance. If you believe this is incorrect, please update the importance.

Changed in juju:
importance: Medium → Low
tags: added: expirebugs-bot
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.