Commit Graph

17 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez ddd5832323 Remove "six" library
Last step to remove "six" library usage in Neutron.

Change-Id: Idd42e0c51c8c3bd598c9cf91602596be238bccae
2020-07-28 16:55:52 +00:00
Oleg Bondarev ab286bcdac Set DB retry for quota_enforcement pecan_wsgi hook
The hook starts a DB transaction and should be covered with
DB retry decorator.

Closes-Bug: #1777965
Closes-Bug: #1771293
Change-Id: I044980a98845edc7b0a02e3323a1e62eb54c10c7
2019-11-08 15:34:17 +04:00
Boden R e4aa5902f7 use context manager from neutron-lib
The neutron.db.api.context_manager already references neutron-lib's
context manager; so consumers of it are already using neutron-lib. This
patch switches neutron's references to the context_manager over to
use neutron-lib's directly rather than that in neutron.db.api.

NeutronLibImpact

Change-Id: I97120faeec73690592ed21a5ec3c6202f61e1429
2018-10-24 07:18:46 -06:00
Brian Haley 7cfdf4aa81 Fix all pep8 E129 errors
Fixed all pep8 E129 errors and changed tox.ini to no longer
ignore them.

Change-Id: I0b06d99ce1d473b79a4cfdd173baa4f02e653847
2018-05-03 13:44:04 +09:00
Inessa Vasilevskaya 7322bd6efb Make code follow log translation guideline
Since Pike log messages should not be translated.
This patch removes calls to i18n _LC, _LI, _LE, _LW from
logging logic throughout the code. Translators definition
from neutron._i18n is removed as well.
This patch also removes log translation verification from
ignore directive in tox.ini.

Change-Id: If9aa76fcf121c0e61a7c08088006c5873faee56e
2017-08-14 02:01:48 +00:00
Ann Kamyshnikova 9195c66cbf Use new enginefacade for quota and provisioning blocks
Use reader and writer for db operations.

Partially-Implements blueprint: enginefacade-switch

Change-Id: I3adaec4cae814c1feb88aa646b99823de9c0eb9e
2017-03-29 14:31:03 +00:00
Duan Jiong c5f5bd0c4f Fix some reST field lists in docstrings
Probably the most common format for documenting arguments is reST field
lists [1]. This change updates some docstrings to comply with the field
lists syntax.

[1] http://sphinx-doc.org/domains.html#info-field-lists

Change-Id: I8fb91bcb8ae4bfbfa68ddf7c38a4f1f5cf548b36
2017-03-23 08:50:01 +08:00
Gary Kotton 4984c7c24e Quotas: add in missing translation
Commit 5d597367cf raised an
exception without a translation.

TrivialFix

Change-Id: Iaa4b4ca2b79505ded35221ab25d439aecf8d6d8a
2016-09-08 05:58:19 -07:00
Kevin Benton 5d597367cf Except if tracked resource registered as countable
If a resource was registered in the quota engine before
being set as a tracked resource, it would have been registered
as a CountableResource instead of a TrackedResource.

This would cause a failure later when the resources were
being unregistered because the quota engine thought it
should have been a TrackedResource and tried to call
unregister_events on it.

This patch just prevents resources from being registered
as both types. It also callse unregister_all_resources as
part of the standard test case cleanup since the vast majority
of tests are using a plugin that may register resources.

Closes-Bug: #1612222
Change-Id: I8a40f38d7c0e5aeca257ba62115fa9b02ad5aa93
2016-09-07 05:22:40 -07:00
LiuNanke 83ef6b5677 Using LOG.warning replace LOG.warn
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning
so we prefer to use warning to avoid DeprecationWarning.

Closes-Bugs: #1529913

Change-Id: Icc01ce5fbd10880440cf75a2e0833394783464a0
Co-Authored-By: Gary Kotton <gkotton@vmware.com>
2016-03-10 11:02:45 -08:00
Doug Wiegley dd726ed494 Move i18n to _i18n, as per oslo_i18n guidelines
- This does NOT break other projects that rely on neutron.i18n,
  as this change includes a debtcollector shim to maintain those
  older entry points, until they can migrate.
- Also updates _i18n.py to the latest pattern defined by oslo_i18n
- Guidance and template are from the reference:
  http://docs.openstack.org/developer/oslo.i18n/usage.html

Partially-Closes-Bug: #1519493
Change-Id: I1aa3a5fd837d9156da4643a367013c869ed8bf9d
2015-12-01 19:29:10 -07:00
Salvatore Orlando 7da1724d44 Improve DB operations for quota reservation
This patch deals with the lock wait timeout and the deadlock errors
observed under high concurrency (api_workers >= 4) with the pymysql
driver. It includes the following changes:

- Stop setting dirty status for resource usage when creating
  reservation, as usage of reserved resources is not tracked anymore;
- Add a variable, increasing delay when retrying make_reservation
  upon a DBDeadlock error in order to reduce the chances of further
  collisions;
- Enable transaction retry upon DBDeadlock errors for set_quota_usage;
- Do not resync quota usage while making reservation. This puts a lot
  of stress on the database and is also wasteful since resource usage
  is very likely to change again once the transaction is committed;
- Use autonested_transaction to simplify logic around when the
  nested flag should be used.

Change-Id: I7a335f9ebea3c0d6fee6e6b757554e045a66075c
Closes-Bug: #1486134
Related-Blueprint: better-quotas
2015-09-07 02:32:51 -07:00
Jenkins 81b2be5d38 Merge "Minor typo fix" 2015-08-20 11:03:33 +00:00
Salvatore Orlando 574b25b857 Reservations support
Add the concept of resource reservation in neutron.
Usage tracking logic is also updated to support reservations.
Reservations are not however available with the now deprecated
configuration-based quota driver.

The base API controller will now use reservations to perform
quota checks rather than counting resource usage and then
invoking the limit_check routine.

The limit_check routine however has not been removed and
depreacated as a part of this patch. In order to ensure all
quota drivers expose a consistent interface, a
make_reservation method has been added to the configuration
based driver as well. This method simply performs "old-style"
limit checks by counting resource usage and then invoking
limit_check.

DocImpact

Implements blueprint better-quotas.

Change-Id: Ifea07f461def564884af5b291c8a56655a4d818b
2015-08-17 15:54:19 -07:00
Amit Saha 65c8da40e4 Minor typo fix
Change-Id: Id6f50b56c9af6a1161e95a3ac0b3411d3513aa2e
2015-08-14 13:28:06 +05:30
Salvatore Orlando b39e1469e8 Add plural names for quota resources
Introduce a 'plural_name' attribute in the BaseResource
class in the neutron.quota.resource module. This will
enable to specify the plural name of a resource when it's
entered in the quota registry.

This will come handy for managing reservations and also
removes the need for passing the collection name when
counting a resource.

Also, the name of the 'resources' parameter for the
_count_resource routine has ben changed to collection_name,
as the previous one was misleading, since it led to believe
it should be used for a collection, whereas it is simply
the name of a collection.

Change-Id: I0b61ba1856e9552cc14574be28fec6c77fb8783c
Related-Blueprint: better-quotas
2015-07-28 11:55:04 -07:00
Salvatore Orlando 3c584084c3 Introduce usage data tracking for Neutron
This patch introduces application logic support for tracking
Neutron resource usage data, thus introducing a different
way of enforcing quota limits, which now relies on records
tracking resource usage for each tenant.

When these records go "out-of-sync" with actual resource usage,
the quota usage table entry is marked "dirty".
And it will be resynchronized the next time a resource count is
requested. Changes in resource utilization are detected using
SQLAlchemy events.

This patch however does not automatically enable resource usage
tracking for any plugin. Plugins must explicitly declare for which
resources they wish to enable tracking. To this aim, this patch
provides the @tracked_resources decorator.

As some operators might wish to not use resource usage tracking, this
patch adds the track_quota_usage configuration option. If set to
False, DB-level usage tracking will not be performed, and
resources will be counted as before, ie: invoking a plugin method.

Usage tracking is performed using a new resource type,
TrackedResource, which can work side by side with CountableResource,
the one Neutron used so far. To this aim a ResourceRegistry class
has been introduced for registering and managing resources. Most
of the resource management code previously embedded in the
QuotaEngine class is being moved to ResourceRegistry as a part of
this patch.

Partially implements blueprint better-quota

Change-Id: If461399900973a38d7b82e0b3ac54fc052f09529
2015-07-28 11:55:03 -07:00