IPA clean up how Error classes set details
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ironic |
Fix Released
|
Low
|
Ruby Loo |
Bug Description
The Error classes in errors.py all (I think) inherit from RESTError class. This class is serializable, and will serialize self.details. Subclasses can modify this by setting their own self.details.
There are two ways that the subclasses can do this:
1. if the parent class's __init__() accepts a 'detail' parameter, the subclass invokes that and passes the detail
2. in the subclass's __init__(), self.details is set to the desired details string
Looking at the classes, there seems to be some confusion (or maybe to hedge their bets), both 1 & 2 above are done. Eg IronicAPIError.
In addition, there was at least one case where unknowingly, someone subclassed directly from RESTError, and thought that passing details to RESTError's __init__() would suffice :-(
It would be good if this file was cleaned up and consistent, so as not to cause confusion. My suggestion is to change RESTError's __init__ to take a details=None parameter, and if details, set self.details = details. (And delete the setting #2 from subclasses unless they are needed.)
Unit tests would be a bonus.
Changed in ironic: | |
status: | New → Triaged |
Changed in ironic: | |
assignee: | nobody → Ruby Loo (rloo) |
tags: | added: agent |
Changed in ironic: | |
assignee: | Ruby Loo (rloo) → Josh Gachnang (joshnang) |
assignee: | Josh Gachnang (joshnang) → Ruby Loo (rloo) |
Changed in ironic: | |
milestone: | none → kilo-2 |
status: | Fix Committed → Fix Released |
Changed in ironic: | |
milestone: | kilo-2 → 2015.1.0 |
Fix proposed to branch: master /review. openstack. org/146924
Review: https:/