This adds caching of resource limits for an Enforcer in order to
improve performance when repeated limit checks are needed. The cache
lasts the lifetime of an Enforcer and is enabled by default. It can be
disabled by passing cache=False when instantiating an Enforcer.
One usage pattern for a caching Enforcer would be to create an Enforcer
per service request so that the caching lives only as long as the
request.
Change-Id: I8e43dceec76aecd2b2ae23a137e56519efe29777
This adds a fixture that can be used by consuming projects to
simulate a set of limits in keystone, without requiring actual
keystone. Currently, consumers have to mock oslo.limit internals (at
least) in order to do testing.
Change-Id: If72050e90ca8b03e26d128c7bbcef6bbea92b501
In multiple situations, it is necessary to be able to probe the limits
set for a project without actually enforcing. Examples:
1. Exposing a usage API where we want to not only report the current
usage, but the limit as well. Otherwise clients have to do their
own calls to keystone and correlation to get a single integer
limit value, which we should be able to expose for them.
2. When checking quota as part of a long-running process of consuming
an unbounded data stream, we need to be able to determine how much
quota remains so that we can stop the transfer if we exceed the
limit. Without this, we have to periodically call to keystone
during the transfer, which is expensive and could fail.
This patch adds a calculate_usage() method to the Enforcer which
calculates the usage using the enforcement model and returns a
mapping of resource names to namedtuples that contain limit and usage
information.
Change-Id: Ic0632cc5ec52aefb85a04f879651963bfa54dcbe
Add file to the reno documentation build to show release notes for
stable/wallaby.
Use pbr instruction to increment the minor version number
automatically so that master versions are higher than the versions on
stable/wallaby.
Sem-Ver: feature
Change-Id: I0ee8832bb010b0929ba0e7a0dd00fa9a399004e7
This patch is the merge of 2 current fixes that need to be solved in the
same time. Indeed each issue lock our gates independently.
Dropping lower constraints testing
We facing errors related to the new pip resolver, this
topic was discussed on the ML and QA team proposed to
to test lower-constraints [1].
I propose to drop this test because the complexity and recurring pain needed
to maintain that now exceeds the benefits provided by this mechanismes.
[1] http://lists.openstack.org/pipermail/openstack-discuss/2020-December/019390.html
Move flake8 as a pre-commit local target.
The goal here is to avoid conflicts between flake8 and hacking version each
2 days.
Inspired from nova's approach[1].
The flake8 version to install will be determined by hacking and
requirements[2] will stay aligned instead of relying on different versions.
[1] https://opendev.org/openstack/nova/src/branch/master/.pre-commit-config.yaml#L26-L35
[2] https://opendev.org/openstack/hacking/src/branch/master/requirements.txt#L1
Co-authored-by: Daniel Bengtsson <dbengt@redhat.com>
Change-Id: I04a845fd98f0d21f7a21dae9f184117263390dd1
flake8 new release 3.8.0 added new checks and gate pep8
job start failing. hacking 3.0.1 fix the pinning of flake8 to
avoid bringing in a new version with new checks.
Though it is fixed in latest hacking but 2.0 and 3.0 has cap for
flake8 as <4.0.0 which mean flake8 new version 3.9.0 can also
break the pep8 job if new check are added.
To avoid similar gate break in future, we need to bump the hacking min
version.
- http://lists.openstack.org/pipermail/openstack-discuss/2020-May/014828.html
Change-Id: I70ca30dd0a5bf0f1aa44f627d92038c826b67174
The docs requirements migrated to doc/requirements.txt
we need not install things from requirements.txt.
Change-Id: Ia65109bbb683489ba9a880d3a41baca5ef560d77
Add file to the reno documentation build to show release notes for
stable/victoria.
Use pbr instruction to increment the minor version number
automatically so that master versions are higher than the versions on
stable/victoria.
Change-Id: I73e3c0ae23f57c57cb3d55157df3cd8024914100
Sem-Ver: feature
Introduced changes:
- pre-commit config and rules.
- Add pre-commit to pep8 gate, Flake8 is covered in the pre-commit hooks.
- Applying fixes for pre-commit compliance in all code.
Also commit hash will be used instead of version tags in pre-commit to
prevend arbitrary code from running in developer's machines.
pre-commit will be used to:
- trailing whitespace;
- Replaces or checks mixed line ending (mixed-line-ending);
- Forbid files which have a UTF-8 byte-order marker
(check-byte-order-marker);
- Checks that non-binary executables have a proper
shebang (check-executables-have-shebangs);
- Check for files that contain merge conflict strings
(check-merge-conflict);
- Check for debugger imports and py37+ breakpoint()
calls in python source (debug-statements);
- Attempts to load all yaml files to verify syntax (check-yaml);
- Run flake8 checks (flake8) (local)
For further details about tests please refer to:
https://github.com/pre-commit/pre-commit-hooks
Change-Id: Ic00da1340d695c7a109f41a09929b654baf995a7
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
This patch bumps bandit allowed version to >=1.6.0,<1.7.0 in order to
avoid the errors detailed here https://github.com/PyCQA/bandit/pull/393
Change-Id: I568123c93c32cb224628c4a8371a9a0e7c19cf67
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
This commit add a new user guide about how a service
developer can easily integrate oslo_limit and use
Keystone unified limit system.
Change-Id: I415fdef757e5f78f1c201c32489bc00a1f3cebd0
Switch to openstackdocstheme 2.2.1 and reno 3.1.0 versions. Using
these versions will allow especially:
* Linking from HTML to PDF document
* Allow parallel building of documents
* Fix some rendering problems
Update Sphinx version as well.
Remove doc requirments from lower-constraints, they are not used for
install. Remove also hacking, the version is ancient and not needed
there either.
openstackdocstheme renames some variables, so follow the renames. A
couple of variables are also not needed anymore, remove them.
Set openstackdocs_auto_name to use project as name.
Change pygments_style to 'native' since old theme version always used
'native' and the theme now respects the setting and using 'sphinx' can
lead to some strange rendering.
See also
http://lists.openstack.org/pipermail/openstack-discuss/2020-May/014971.html
Change-Id: I5ec9dda8582f55fc0b287c422d5c43ad2e23b9b8
Python modules related to coding style checks (listed in blacklist.txt in
openstack/requirements repo) are dropped from lower-constraints.txt
as they are not actually used in tests (other than pep8).
more info: https://github.com/openstack/requirements/blob/master/blacklist.txt
Change-Id: I9360028e96dd2b99fee1e31ebf9645e44e845d5f
These translation sections are not needed anymore, Babel can
generate translation files without them.
Change-Id: I18696d80bad13d2f3e31ed1ad8f046fb9a202e16
Add file to the reno documentation build to show release notes for
stable/ussuri.
Use pbr instruction to increment the minor version number
automatically so that master versions are higher than the versions on
stable/ussuri.
Change-Id: I28d813d853e7961adcf617e452769b64f9e7eccc
Sem-Ver: feature
The repo is Python 3 now, so update hacking to version 2.0 which
supports Python 3.
Blacklist: W504 line break after binary operator
Change-Id: I7ca780a2cff32031c562482b804888e5d49712c1
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: I0d2b84e2ed627481118151b36386014ed0930452
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Update the minversion parameter to use the python -m pip to install
python packages:
https://tox.readthedocs.io/en/latest/changelog.html#id185
It's recommend to use this. Remove the useless install_command
parameter.
Change-Id: Ic5c0f747c8d579ce3369635b67cdbf2d134c175d