placement reshaper doesn't clear all inventories for a resource provider
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Medium
|
Eric Fried |
Bug Description
The /reshaper API is willing to accept an empty dictionary for the inventories attribute of a resource provider. This is intended to mean "clear all the inventory".
However, the backend transformer code is not prepared to handle this:
File "nova/api/
File "/mnt/share/
return fn(*args, **kwargs)
File "nova/api/
rp = new_inv_
File "/mnt/share/
return self.objects[index]
IndexError: list index out of range
This happening because 'new_inv_list' can be empty at
for rp_uuid, new_inv_list in inventories.
rp = new_inv_
If the length of new_inv_list is zero we need to do nothing for this iteration though the loop.
Then a few lines later at
for rp_uuid, new_inv_list in inventories.
# TODO(efried): If we wanted this to be more efficient, we could keep
# track of providers for which all inventories are being deleted in the
# above loop and just do those and skip the rest, since they're already
# in their final form.
We have the same IndexError problem and need to behave differently.
A thing we might do is instead of using the resource_provider object on the (maybe not there) inventory objects, is create a new object: we have the rp_uuid.
summary: |
- placement reshaper doesn't clearing all inventories for a resource - provider + placement reshaper doesn't clear all inventories for a resource provider |
Changed in nova: | |
assignee: | Eric Fried (efried) → Chris Dent (cdent) |
Changed in nova: | |
assignee: | Chris Dent (cdent) → Eric Fried (efried) |
We still need to be careful not to duplicate rp objects, because of the generation conflict thing we already saw. I think we should whip through the old/new inventory objects (and maybe the allocation objects too) and build up a dict of rp_uuid: rp_obj to use in those two loops so we don't ever have to assume [0] exists.
I'll work through something this morning.