Ask Your Question

How to reset incorrect quota count?

asked 2013-04-24 05:25:50 -0500

ikke gravatar image

updated 2013-04-24 13:19:03 -0500

smaffulli gravatar image

I run into a situation where openstack didn't allow me to start new machines. It complained to me (and logs) that quota for vCPUs exceeded. Using 8/8 vCPUs. That was incorrect, since I was using only three vCPUs.

I believe the error might have been caused possibly by deleting some machines that never succeeded to boot, but entered Error state instead. Who knows.

So the question was how to fix the quota?

edit retag flag offensive close merge delete

5 answers

Sort by » oldest newest most voted

answered 2013-04-24 05:28:28 -0500

ikke gravatar image

updated 2014-06-23 01:32:36 -0500

I noticed the count was wrong in the nova table in database. The fix that helped was that I set it manually to '-1' to force nova to recount the cpus:

mysql -u nova -p<password> nova
select * from quota_usages;
update quota_usages set in_use='-1' where project_id='<my project id>';

After I started a new instance, I was able to run it and quota numbers got updated!

UPDATE for Icehouse: It's not -1 any longer, but 0 instead.

update quota_usages set in_use='0' where project_id='<my project id>';
edit flag offensive delete link more


thank you very much. Just enabled me fix a new openstack installation that had exceeded its quota.

sanjay m gravatar imagesanjay m ( 2013-04-30 22:56:26 -0500 )edit

Hi is there a bug logged against this issue? if so can someone point me to it?

the_gent gravatar imagethe_gent ( 2013-12-16 04:43:37 -0500 )edit

I'm seeing this problem in Icehouse and the quota numbers aren't being updated, even after I've set the in_use rows to 0 and started an instance, for a given project. Are any other settings needed? Or does it take a while?

verdurin gravatar imageverdurin ( 2014-09-12 11:13:20 -0500 )edit

Quota numbers aren't being updated for me too, even if I've set as well the in_use field to 0. I don't believe that is a matter of time, because I have 3 active instances and if I create another instance the in_use value increases only by 1.

pernacentus gravatar imagepernacentus ( 2014-09-19 05:41:46 -0500 )edit

I don't know where Icehouse Note came from, but right now I still see the following code there:

        elif user_usages[resource].in_use < 0:
            # Negative in_use count indicates a desync, so try to
            # heal from that...
            refresh = True
max-lobur gravatar imagemax-lobur ( 2015-02-13 13:17:11 -0500 )edit

answered 2014-06-21 10:18:49 -0500

kfox gravatar image

Just tried this with icehouse and it made things worse. I'd recommend against this solution in the future.

edit flag offensive delete link more


It's still about the same. You just should not use the -1 any longer, but 0. I just did this the last week when I run into the same problem again:

update quota_usages set in_use='0' where project_id='<my project id>';
ikke gravatar imageikke ( 2014-06-23 01:28:40 -0500 )edit

answered 2019-02-02 01:18:51 -0500

Vinoth gravatar image

The “quota_usage_refresh” feature in nova client CLI allows operators to quickly unblock users without manually running any queries against the database or temporarily increase the quota..

$ nova-manage project quota_usage_refresh --project <project name=""> --user <user name="">


Vinoth Kumar Selvaraj

edit flag offensive delete link more

answered 2014-09-01 12:56:21 -0500

yottatsa gravatar image

updated 2014-10-08 06:02:17 -0500

Here is an SQL snippet for usage recalculation

update quota_usages, (select usage_id, sum(delta) as sum from reservations where project_id='86d829ffc0ff4efb943131f7d2a18d52' and deleted!=id group by usage_id) as r set quota_usages.in_use = r.sum where = r.usage_id;
update quota_usages, (select distinct(usage_id) as usage_id from reservations where project_id='ad3e3ee7a08d45df965908704f29b873' and deleted=id ) as r set quota_usages.in_use = 0 where = r.usage_id;
edit flag offensive delete link more

answered 2014-07-24 05:43:16 -0500

On Havana, I moved some instances from one project to another via cli with command like:- mysql> update nova.instances set project_id = 'xx00968bc4854852b87edbac32f4ff94' where reservation_id = 'r-00cw2es8';

This worked, but the project summaries are now wrong in both the source and destination projects.

I tried setting the in-use to -1 for the source project id, the sql update worked, but Horizon was broken and produced and error page for any requested url.

To fix this, I had to update the in_use column with the correct value (fortunately I had the original select * from quota_usages still on screen. However, just doing an update on the required resource updated multiple rows. After updating all the required resources, Horizon worked again. But now the totals were wrong as the multiple row updates were just all added together. These rows needed adjusting manually including the id field in the update statement so the totals matched to actual usage values:- mysql> update quota_usages set in_use='9' where project_id='xx7d3686c3f74eb28ea15cb659c8019e' and resource='cores' and id='93'; Query OK, 1 row affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0

The destination project shows zero usage for new instances, so this will need adjusting manually too.

edit flag offensive delete link more


Update. In the destination project where all the totals were showing zero, creating an instance and then destroying it set the totals to the correct figures without database tinkering. Maybe setting to 0 instead of -1 would allow this is the source project. This is the case for Icehouse (see above) but maybe it applies to Havana too. Untested though.

AndrewS gravatar imageAndrewS ( 2014-07-25 11:31:06 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools



Asked: 2013-04-24 05:25:50 -0500

Seen: 11,165 times

Last updated: Feb 02 '19