7 Commits

Author SHA1 Message Date
Hervé Beraud
9caec06faf Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I79f231823939e421a04377ca19e2e65b12d9b26a
2020-06-02 20:40:20 +02:00
Dirk Mueller
5259c08c09 Always close all passed in fds beyond sensible_fd_limit on launch
Change Idd98c183eca3e2df8648fc0f37d27fe9cc6d0563 stopped closing
filedescriptors beyond the sensible_fd_limit. With this patch
the previous behavior is restored. We can close the fds more efficiently
by just iterating over /proc/self/fd on Linux and only change
the rlimit/MAXFD setting when successful.

Change-Id: I3b481ddd14ae2b948270d715aad157cf3996def7
2019-03-23 11:30:30 +01:00
Lucian Petrut
8f148f5e9e Fix portability issue
The use of the "resource" module now prevents oslo.rootwrap from
being imported on Windows.

Although oslo.rootwrap is not effectively used on Windows, it's
important for it to at least be importable, since it's widely
used throughout OpenStack projects without having platform checks
in place.

This change checks if the "resource" module is avaialble before
attempting to use it.

Change-Id: I2391315f77718a3c9eb9fc8c03a6882237f33548
Closes-Bug: #1804639
2018-11-22 13:22:52 +02:00
Dirk Mueller
c0a8699820 Run rootwrap with lower fd ulimit by default
On Python 2.x, a subprocess.Popen() with close_fds=True will
fork and then close filedescriptors range(3..os.sysconf("SC_OPEN_MAX")),
which thanks to Kernel PTI (Kaiser patches) is significantly slower
in 2018 when the range is very large. With a soft limit of 1048576,
benchmark.py reports an overhead of ~ 400ms without this patch and 2ms
with the patch applied. This patch adds a configuration option and
sets a more sensible default of 1024 file descriptor limit by default.

Closes-Bug: 1796267
Change-Id: Idd98c183eca3e2df8648fc0f37d27fe9cc6d0563
2018-10-09 12:12:46 +02:00
fumihiko kakuma
6af1b2178f Python 3: Don't use BaseException.message attribute
In Python 3, BaseException.message is removed.
So we use args attribute instead.

Change-Id: I8f97c0b0452f348acef20e9d248f02b83cec2562
2015-08-26 16:40:42 +09:00
Davanum Srinivas
1782ef1444 Speed up non-daemon rootwrap command line invocation
Move the import to the spot where we really need it. This
speeds up the command line invocation (non-daemon) a bit.

Closes-Bug: #1440744
Change-Id: I401c290e0b61912b5dce106d3fdda91795a8cb12
2015-04-06 09:59:00 -04:00
Doug Hellmann
bdb739e249 Move files out of the namespace package
Move the public API out of oslo.rootwrap to oslo_rootwrap. Retain
the ability to import from the old namespace package for backwards
compatibility for this release cycle.

bp/drop-namespace-packages

Change-Id: Ifed1a99e5ea6d999760731867c4294707698d41c
2014-12-18 16:08:01 -05:00