Comment 11 for bug 1224453

Revision history for this message
Mike BRIGHT (k5-openstack) wrote :

I've been looking at this in the debugger and I see that it's in quota.py: quota_reserve() that the OverQuota exception is thrown.
I could add the current headroom calculation code in that function and return headroom as one of the "exc.kwargs" arguments.

HOWEVER, as we don't have instance_type available in that function, headroom would still require to be corrected for the case of quota_vcpus == -1, from outside the function (at two places in compute/api.py).
Because if quota_vcpus is -1 and instance_type['vcpus'] is set then we should set headroom as:
    headroom['cores'] = headroom['instances'] * instance_type['vcpus']

So can someone advise here?
Is there a way of passing instance_type into QUOTAS.reserve ... down to quota_reserve() ?
I'm unsure of the plumbing.

Or should I correct headroom (yuk!) after receiving the OverQuota exception (in 2 places in compute/api.py).
In that case I still suggest the _calculate_headroom() function previously proposed here.

NOTE: As a separate issue, I have not understood Phils' suggestion that QUOTAS.reserve be called several times ...