Refresh quotas usage¶
For some reasons [*], the quotas usage can be out of sync. When a quota is wrongfully reached, a user cannot launch new VMs anymore. This “refresh” feature allows operators to quickly unblock users without manually running queries against the database or temporarily increase the quota.
Quotas usage can be out of sync in quota_usages table. The number of used resources may not reflect the actual use. For instance we can see 7 cores used while the actual use is only 4.
An end user can be blocked if a quota is wrongfully reached for a resource type.
If a refresh quotas usage feature is implemented in Nova an operator can correct the usage without running a SQL query directly on the database.
Currently, the “refresh quotas usage” feature is hidden inside SQLAlchemy
As described in “Alternatives” paragraph, the function
nova.db.sqlalchemy.api.quota_reserve() can refresh the database under
The change consists to:
Create a function in the DB API to refresh quotas usage:
Do an “extract function” refactoring on
nova.db.sqlalchemy.api.quota_reserve()to implement the aforementioned
quota_usage_refresh()DB API. That is:
nova.db.api.quota_usage_refresh()feature through a nova-manage command.
The nova-manage command would look like:
$ nova-manage project quota_usage_refresh --project <Project name> [--user <User name>] [--key <Quota key>]
--key is omitted, all quota resources are refreshed.
--user is optional since some resources are per-project quotas,
like fixed_ips, floating_ips and networks. Similarly, the
command takes an optional user.
$ nova-manage project quota_usage_refresh --project demo --user john_doe --key cores $ nova-manage project quota_usage_refresh --project f85aa788e8ee48fca3da27e0579d3597 --key cores
Another nova-manage command¶
Another nova-manage command can use the already implemented
Here is the docstring of this function, note the “for a particular user”:
Reset the usage records for a particular user on a list of resources. This will force that user's usage records to be refreshed the next time a reservation is made. Note: this does not affect the currently outstanding reservations the user has; those reservations must be committed or rolled back (or expired). :param context: The request context, for access checks. :param resources: A list of the resource names for which the usage must be reset.
“Reset” means “set to -1 in database”.
The resulting command would be:
$ nova-manage project quota_usage_reset --project <Project name> --user <User name> [--key <Quota key>]
--key is omitted, all quota resources are reset.
nova/cmd/manage.py is modified.
Unlike quota_usage_refresh, no changes are required at the database API level.
The main difference with quota_usage_refresh is that the user won’t see actual quota usages until the next reservation.
Credits: This command is proposed by Joe Gordon (cf. patch set 2)
We can enable quotas “auto refresh” in nova.conf thanks to:
until_refresh (IntOpt) Count of reservations until usage is refreshed
max_age (IntOpt) Number of seconds between subsequent usage refreshes
These two settings (disabled by default) allow to refresh quotas usage but only during a quota reservation. The algorithm is:
until_refresh or max_age threshold reached?
If yes: refresh
Let’s take an example: a quota of 10 instances is set on a tenant.
The quota is wrongfully reached:
nova absolute-limits shows totalInstancesUsed = 10
nova quota-show shows instances = 10
The actual instances number is 9.
When a user runs a
nova boot he will get an error: “Quota exceeded”.
Many users will stop here and contact their support. Actually, a second
nova boot might succeed if the first one has refreshed the quotas usage
(depending on until_refresh or max_age threshold).
We would need to improve this behavior but it’s off topic here.
Note that on Horizon a user will not able to spawn an instance (corresponding
to the first
nova boot) because the button is disabled when a quota is
until_refresh or max_age need to be enabled but a cloud operator may not want to enable them if only few tenants encounter a bug on quotas usage.
Even with these two settings enabled, we can’t force a refresh.
Data model impact¶
REST API impact¶
Other end user impact¶
The feature hits the table quota_usages the same way
nova.db.sqlalchemy.api.quota_reserve() does when triggering a refresh.
Other deployer impact¶
Other implementations of
nova.db.api should implement
Handle nested projects? https://blueprints.launchpad.net/nova/+spec/nested-quota-driver-api
- Primary assignee:
Chuck Carmack <firstname.lastname@example.org>
- Other contributors:
Romain Hardouin <email@example.com>
Not a big change, this BP can be submitted as a whole.
Change the DB API
Implement the nova-manage command
In-tree unit and functional testing should be sufficient.
Document the new nova-manage command.
“nova quota statistics can be incorrect”: https://bugs.launchpad.net/nova/+bug/1284424
“Test job failes with FixedIpLimitExceeded with nova network”: https://bugs.launchpad.net/nova/+bug/1353962
“How to reset incorrect quota count?”: https://ask.openstack.org/en/question/494/how-to-reset-incorrect-quota-count/
“nova ‘absolute-limits’: […] (they are wrong)” http://lists.openstack.org/pipermail/openstack/2014-November/010250.html
“[…] usage now out-of-sync”: https://ask.openstack.org/en/question/11943/deleted-vms-still-showing-in-nova-dashboard-usage-now-out-of-sync/
For information, on Horizon side:
- “absolute-limits sometimes returns negative value” :
Re-proposed with No changes
Re-proposed with 2 changes