Commit Graph

45 Commits

Author SHA1 Message Date
Zuul 592d8ac51a Merge "Make greenlet optional" 2024-02-13 15:43:20 +00:00
Takashi Kajinami 15108e3be1 Remove logic for python 2 support
... because python 2 support was already removed.

Change-Id: I57e8ac2549ecf170d6b43bc0557fd388e025e536
2024-02-07 04:37:43 +00:00
Takashi Kajinami e43ae1115c Make greenlet optional
The greenlet library is not always used. It is used to capture detail
of green threads but this part can be skipped in case greenlet is not
present.

Also eventlet in test requirements is not used and can be removed.

Change-Id: I57edfe4d975ce42ca92a9242d4b32e69d1cec268
2024-02-07 11:56:36 +09:00
Takashi Kajinami db11260c11 GMR: Allow disabling signal handler
Some services such as nova introduced GMR for API wsgi application
so that GMR can be generated via a file handler. However the current
setup method tries to register signal handler and causes warnings.

For example we are seeing the following error when starting nova-api
by apache + mod_wsgi.

mod_wsgi (pid=80323): Callback registration for signal 12 ignored.
  File "/var/www/cgi-bin/nova/nova-api", line 52, in <module>
    application = init_application()
  File "/usr/lib/python3.9/site-packages/nova/api/openstack/compute/wsgi.py", line 20, in init_application
    return wsgi_app.init_application(NAME)
  File "/usr/lib/python3.9/site-packages/nova/api/openstack/wsgi_app.py", line 128, in init_application
    init_global_data(conf_files, name)
  File "/usr/lib/python3.9/site-packages/nova/utils.py", line 1122, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/nova/api/openstack/wsgi_app.py", line 105, in init_global_data
    gmr.TextGuruMeditation.setup_autorun(
  File "/usr/lib/python3.9/site-packages/oslo_reports/guru_meditation_report.py", line 152, in setup_autorun
    cls._setup_signal(signal.SIGUSR2,
  File "/usr/lib/python3.9/site-packages/oslo_reports/guru_meditation_report.py", line 185, in _setup_signal
    signal.signal(signum,

This introduces the new argument so that we can disable signal handler
completely to avoid such warnings.

Change-Id: I95170542fecb493260a22d9148f3a2777207cb0e
2023-08-03 21:37:33 +09:00
Johannes Kulik 68bc329964 Support integer keys of dicts in text serialization
When the config contains a DictOpt that accepts integer keys, the Guru
Meditation Report fails to serialize. Even if current OpenStack code
might not contain such dicts, it's possible that downstream add such
options. Therefore, we change the code to support both dicts with only
integer keys and - just in case - mixed-key dicts.

Change-Id: I44343a8c306c96fc8dc078a76e744cf8b897d8d8
2021-12-20 11:19:19 +01:00
wangzihao a96ee02b24 Replace concatenation with f-strings
Use f-strings instead concatenation to make it more readable and faster.

Change-Id: I208bd44c063756be85c836e1b30290e6c09f2101
2020-12-11 15:45:20 +00:00
wangzihao a2122e7432 Remove all six usage
Remove six Replace the following items with Python 3 style code.

- six.string_types
- six.text_type
- six.itervalues
- six.StringIO

Change-Id: I32401859129843242922f1d0510b21e32bb7d8cc
2020-10-14 10:24:52 +08:00
Hervé Beraud 1976cc33f1 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: Ia06ab693446bbdb3ed76bcca6bf4cc6d97d7f764
2020-06-02 20:40:02 +02:00
Zuul 314c4e7915 Merge "Use unittest.mock instead of third party mock" 2020-04-06 15:06:02 +00:00
Andreas Jaeger 4838541e98 Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Remove hacking and friends from lower-constraints, they are not needed
for installation.

Change-Id: I76369aad2778418182eab7c3eaf331b8d6b8fb1d
2020-04-02 14:59:15 +02:00
Sean McGinnis cc7f78cfa6
Use unittest.mock instead of third party mock
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: I0ec3d1c0f53bf859ea1ec115ebb47f1d5f3b217c
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-03-31 14:43:17 -05:00
Stephen Finucane 1209fb97c7 Switch from 'collections' -> 'collections.abc'
Resolve the following deprecation warnings on Python 3.x:

    DeprecationWarning: Using or importing the ABCs from 'collections'
    instead of from 'collections.abc' is deprecated since Python 3.3,and
    in 3.9 it will stop working"

Note that even though we're in Ussuri, I've kept this Python 2
compatible since we haven't done all the other work to mark this
package as Python 3-only.

Change-Id: Iff4cf1871a6a91d91da03d9b79ef61e715a979cf
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-12-05 14:55:52 +00:00
ZhijunWei 8171c03846 Update hacking version
Use latest release 1.1.0 and compatible changes w.r.t pep8

Change-Id: I8c82e52e03b2489aca0b70de761da5ac328c7b9c
2019-02-17 11:16:48 +08:00
Ben Nemec 98c0d2c1db Update unit test to reflect latest oslo.config
Because we added the default config_source opt in oslo.config, it
is now showing up in the GMR output and needs to be included in the
expected content.  However, for lower constraints testing we also
need to continue to support the older versions without config_source,
so the target_str is built dynamically based on whether the opt
exists.

Change-Id: I20b01285000ce84b69e8bd3cee8078edf03616f8
2018-08-02 15:31:08 +00:00
OpenStack Proposal Bot eb3d36a0b4 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I875e75d78e8028aee2256ccf4df87d367be5081a
2018-03-01 06:04:38 +00:00
ChangBo Guo(gcb) 4dde5f3cb2 Add bandit to pep8 job
Add the bandit security scanner to the pep8 job.
* skip B314,B405
* Don't use '/temp/file'

Change-Id: I5ae66767178d037d312eb2ab0374dd6f137ecc7b
2017-12-12 14:42:13 +08:00
Jenkins b5d9bb98c3 Merge "Imported Translations from Zanata" 2017-10-09 03:28:56 +00:00
Jenkins 07afa7df4a Merge "Remove psutil 1.x compat wrapping" 2017-10-08 17:34:40 +00:00
OpenStack Proposal Bot 00a3a497eb Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I7950aaaca82915230f13ed92cbea9f8347690edb
2017-10-08 08:25:08 +00:00
Dirk Mueller 21cbc5db00 Remove psutil 1.x compat wrapping
oslo.reports requires psutil at least to be 3.x, so the compat
code paths for 1.x can be removed safely.

Change-Id: If5de0051f2cd131db2f2b0b2919082e1623c29aa
2017-09-28 18:03:27 +02:00
Jenkins 5e69872b3d Merge "Update the documentation link" 2017-09-08 06:17:46 +00:00
loooosy 9218d7e739 Update the documentation link
This patch is proposed according to the Direction 10 of doc
migration(https://etherpad.openstack.org/p/doc-migration-tracking).

Change-Id: I00622c9e17643c17af1497d199c9445aa1ba8166
2017-08-23 15:12:32 +08:00
Adam Harwell 36d97a4f42 Remove SIGUSR1 handler, which was deprecated after Ocata
Change-Id: I4d068bba3f395969a7bcb1e83a2c4fbc2cb304d4
2017-08-21 16:38:37 -07:00
D G Lee cba09827c6 Remove log translations
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: Ic537412399b1cbc7b6e921f4d1c5004189067e1d
Closes-Bug: 1674577
2017-03-24 05:43:44 +00:00
gecong1973 caf139164f Fix a typo
TrivalFix

Change-Id: I3f9120ca58c5d4a8aff4a341048a2e5e3950e399
2016-11-21 09:36:53 +08:00
Jenkins c1c40325cd Merge "Use file modification events instead of signal handler" 2016-06-15 04:04:49 +00:00
Ivan Kolodyazhny d23e0a65b2 Use file modification events instead of signal handler
In case if application is under Apache+mod_wsgi it is not recommended to
use signals [1]. We need to have configuration option for handling
'touch file' event instead of signal.

Alternative solutions:
1) watchdog: can monitor only directories, has issues with eventlet [2].
2) inotify: works only with linux-based systems.

[1]
https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIRestrictSignal

[2] https://github.com/gorakhargosh/watchdog/issues/332

Change-Id: I6ef02457f21da8e6fbd50e57bfa503b3c31ddd76
Implements: blueprint guru-meditation-report-file-touch
2016-06-13 18:25:14 +03:00
OpenStack Proposal Bot 5daba93611 Imported Translations from Zanata
For more information about this automatic import see:
https://wiki.openstack.org/wiki/Translations/Infrastructure

Change-Id: I6422647fb1eb5272940974a3537cb855303db67a
2016-06-11 06:36:21 +00:00
Andreas Jaeger 2f01d5d635 Update translation setup
Follow new infra setup for translations, see spec
http://specs.openstack.org/openstack-infra/infra-specs/specs/translation_setup.html
for full details.

This basically renames
oslo.reports/locale/oslo.reports.pot to
oslo_reports/locale/oslo_reports.pot. For this we need to update
setup.cfg.

Update also domain name in i18n.py.

The project has no translations currently, let's remove the outdated
pot file, the updated scripts work without them. So, we can just
delete the file and once there are translations, an updated pot file
together with translations can be imported automatically.

Change-Id: Id9b9865ee17375290357887077d3230a3e4ff949
2016-01-29 11:42:04 +01:00
Nikola Dipanov ebc7a844ad Print the traceback if there was an exception in run()
In case run() method fails, all we get is a terse "Unable to run Guru
Meditation Report!" message on stderr.

This patch also prints the traceback for easier debugging in the
unlikely event that GMR fails.

Change-Id: I99d4e0f1ed3ea608aa285f34314339b0939c5651
2015-12-18 23:50:01 +00:00
Nikola Dipanov 6681a45b6a Rename signal handler argument to 'frame'
The object that is passed to signal handler functions is a frame object.
Traceback is the name of a built in module. Let's be clear.

Note that there are other places in the code where this unfortunate
naming happened, like in the keyword argument of the TextGuruMeditation
__init__ method. We can't really change that one as it's part of the
public API.

Change-Id: I11ca5cba3475a82a35c8e9fdb82e2529e5fa7b74
2015-12-18 23:49:55 +00:00
ChangBo Guo(gcb) b7f44845dd Drop python 2.6 support
Change-Id: If9de2bd4c831dc950dc1ca89b3c291c23de1c2c4
2015-11-23 14:59:11 +00:00
Jenkins 76688e8369 Merge "Fix a typo in process.py" 2015-11-20 19:37:35 +00:00
Davanum Srinivas 764b8f0f9f Fix Transition to SIGUSR2 in oslo.reports breaks upgrade
In I9d3b6079ba2cca41fe4723723a6f80b2c3c0b9c0, we broke backward
compatability when we switched from SIGUSR1 to SIGUSR2. This breaks
grenade jobs (Example https://review.openstack.org/#/c/238479/).

So for now, let's register both SIGUSR1 and SIGUSR2 and trigger a
warning in the log that SIGUSR1 has been deprecated. We should
remove use of SIGUSR1 in the O release. Hopefully this does not
break anything as when running under mod_wsgi SIGUSR1 is just
ignored (and SIGUSR2 will work) and both signals will work
under eventlet.

Closes-Bug: #1510740
Change-Id: I54ba70557f441fbd10eb085f79d594a9a33e1f11
2015-11-06 06:42:54 -05:00
Daisuke Fujita 928e1e8161 Fix a typo in process.py
1. "formm" to "form"

Change-Id: I71e181e4b42865b2d74c50de5a99384a4726b199
2015-10-13 19:44:44 +09:00
Kashyap Chamarthy 45b1c02d11 guru_meditation_report: Use SIGUSR2 instead of SIGUSR1
Currently the setup_autorun() method expects the user-defined signal,
SIGUSR1, to generate Guru Meditation Report upon killing a Nova Compute
process, while supplying the said signal.

However, testing in a DevStack environment, manually attempting to kill
a Nova Compute process with SIGUSR1 [kill -s USR1 `pgrep nova-compute`]
does not result in the process being terminated, and no error report is
generated.

It turns out[*] that SIGUSR1 is used by Apache 'mod_wsgi'.

Using, the other user-defined signal, SIGUSR2 resolves this issue (i.e.
'nova-compute' process is terminated, and the Guru Meditation Report is
generated successfully).

So, use the signal USR2 instead of USR1.  Also, update the corresponding
tests.

DocImpact: With this patch merged, to generate a successful Guru
           Meditation Report, supply the signal USR2 while killing a
           Nova Compute process [`kill -s USR2 `pgrep nova-compute`].

[*] https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIRestrictSignal

Change-Id: I9d3b6079ba2cca41fe4723723a6f80b2c3c0b9c0
2015-09-14 16:51:33 +02:00
Davanum Srinivas c8980d92f4 Add a configuration for the directory to generate gmr
If projects choose to have their own config parameter, they
can use setup_autorun's log_dir parameter. if they want
to let oslo.report's manage the configuration, they will
have to call set_defaults and then use setup_autorun's
conf parameter.

Change-Id: I9ed0191628f2d552acd8130687b636671bc07a3e
2015-08-25 22:22:56 -04:00
Jenkins 34f0982241 Merge "Fix GMR break with new psutil versions" 2015-07-19 16:18:38 +00:00
Doug Hellmann 1eb6d65893 Fix mock of open() for mock 1.1.0
Mock out open() properly.

Change-Id: Iae77d83593a53064b2284fb4d5d1a4346db65bb4
2015-07-10 13:21:37 +00:00
Davanum Srinivas f62039a851 Fix GMR break with new psutil versions
psutil 2.x and above has a lot of API changes as described in:
https://github.com/giampaolo/psutil/blob/master/HISTORY.rst

So we should work correctly with both old and new psutil versions
by using a version check and use the correct method/attributes.

Note that we cannot remove the g-r cap until all the projects have
switched to oslo.reports (OR we fix oslo-incubator GMR code and have
sync'ed all the consuming projects). So this review is the first
step in a long process of switching all consumers of GMR to use
what we have in oslo.reports.


Depends-On: I0f07858e96ea3baf46f8a453e253b9ed29c7f7e2
Depends-On: I33bd2d9dff9cb7dc1a50177db7286b7317966784

Closes-Bug: #1430231
Change-Id: I52bc6898d098f599c12204fc6d6eb269e2c884cb
2015-07-06 00:21:12 +00:00
zhangchunlong1@huawei.com 99a11312ed Guru Meditation Reports broken without version_string
The versions from many openstack projects don't provide the
vendor_string,product_string,version_string_with_package.
We need to keep compatible with these projects.

Closes-Bug:#1456465
Change-Id: I688ef29b84541d3261f6b9395b3f591b276aa071
(cherry-picked from oslo-incubator commit
14874b8a836b9580a94a118ed535898cfa76362f)
2015-06-22 16:57:05 -04:00
Davanum Srinivas 7a6ccda607 Fix intermittent test failures because of sort order
Both py27 and py34 jobs fail intermittently and i can
recreate the problem even in my local environment by
repeatedly running "tox -e py27,py34". Fixing up the
sort order helps fix the this issue.

Change-Id: I680c8e986af9177c759740ecb8b94b288386c1bf
2015-06-19 15:42:43 -04:00
Solly Ross 6bfdb33cc9 Graduation Prep: Use six.text_type instead of str
Previously, `str()` was used to convert things into strings.
This will not work for unicode messages in Python 2, so
everything was converted to using `six.text_type` instead.
2015-06-03 14:45:50 -04:00
Solly Ross 4faad94ced Graduation Prep: Initial Import Fixup
This commit fixes up the initial import, correcting import paths,
moving some code into a "private" module, updating requirements
files, etc.
2015-06-03 13:46:39 -04:00
Solly Ross 01d69037e0 exported from oslo-incubator by graduate.sh 2015-06-03 12:49:50 -04:00