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 ...
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). type['vcpus' ] is set then we should set headroom as: 'cores' ] = headroom[ 'instances' ] * instance_ type['vcpus' ]
Because if quota_vcpus is -1 and instance_
headroom[
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). headroom( ) function previously proposed here.
In that case I still suggest the _calculate_
NOTE: As a separate issue, I have not understood Phils' suggestion that QUOTAS.reserve be called several times ...