Poor error message during collect-metrics
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-
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 ErrRestrictedCo
...
func (*RestrictedCon
return nil, ErrRestrictedCo
}
And all functions just return ErrRestrictedCo
Given that NotImplemented already adds 'not implemented' as a suffix, these should be updated to something more like:
func restrictedConte
return errors.
}
func (*RestrictedCon
return nil, restrictedConte
}
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.
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.