quota_reserve headroom might be wrong if project_quotas != user_quotas
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Low
|
Liyingjun |
Bug Description
Looking at this code:
https:/
Notice the headroom variable is created based on usages and user_quotas:
headroom = dict((res, user_quotas[res] -
but the usages variable is based on whether or not project_quotas == user_quotas:
if project_quotas == user_quotas:
usages = project_usages
else:
usages = user_usages
So it appears that headroom could be incorrect if project_quotas != user_quotas.
Looking at what uses headroom, the compute API uses this in the instance create and resize flows. For resize it's just using headroom to plug into an error message for the TooManyInstances exception.
In the create flow (_check_
We should probably just remove the headroom calculation from quota_reserve and let the caller figure it out and what needs to be done with it. It's also odd that this is happening in the DB API because it's dealing with instance quotas but maybe I'm not doing anything with instance quotas, maybe I'm doing things with security group or fixed IP quotas - so this code seems to be in the wrong place. Maybe it's just conveniently placed here given the other data already in scope from the database.
Changed in nova: | |
importance: | Undecided → Low |
status: | New → Confirmed |
Changed in nova: | |
assignee: | nobody → Liyingjun (liyingjun) |
Changed in nova: | |
milestone: | none → kilo-1 |
status: | Fix Committed → Fix Released |
Changed in nova: | |
milestone: | kilo-1 → 2015.1.0 |
Agree with fixing this by removing the headroom calculation from the db layer. I don't like the hardcoding of things like 'cores' and so forth in there related to this. I think returning current usage+reservations along with quotas is enough to let the caller to compute headroom itself on the resources it cares about, etc...