Commit Graph

41 Commits

Author SHA1 Message Date
Matthias Runge ca45bbdca0 Retire panko, the code is no longer maintained.
The contents of this repository are still available in the Git source
code management system. To see the contents of this repository before it
reached its end of life, please check out the previous commit with
"git checkout HEAD^1".

For any further questions, please email
openstack-discuss@lists.openstack.org or join #openstack-telemetry on OFTC.

Change-Id: Ic8a7001e708d8da7cf8951eefd0a96762ea5fa46
2021-05-27 11:36:44 +02:00
wangzihao f95cff99e2 Remove six
Remove six Replace the following items with Python 3 style code.

- six.text_type
- six.PY3
- six.moves.urllib
- six.string_types
- six.iteritems
- six.integer_types
- six.binary_type
- six.add_metaclass
- six.moves.reprlib

Depends-on: https://review.opendev.org/c/openstack/telemetry-tempest-plugin/+/770955
Change-Id: Ia301d56d675557e81b873ddd68f1faeb051dfe93
2021-01-15 16:48:21 +00:00
Zuul 046c9460c6 Merge "Add max_count argument for clear_expired_data call" 2020-07-02 12:49:55 +00:00
Ivan Kolodyazhny ec84ed8aa7 Add max_count argument for clear_expired_data call
When thare're a lot of events in the database panko-expire
consumes a lot of memory to delete all records with a single
call. To avoid this behaviour a new config option
`events_delete_batch_size` was introduced.

Change-Id: Icf83ffe089301b3782273923f18efd4d209131c2
2020-07-02 10:31:06 +03:00
Hervé Beraud d2453d77b6 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: Ieb7f2b1ede23d9bcf0f87620e87743a1531bb494
2020-06-02 20:42:47 +02:00
Andreas Jaeger e66d3e7599 Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Update local hacking checks to work with new flake8 version.

Change-Id: Id5d224358b44fd7ab4bd3d08f1db6b6faf54042f
2020-04-03 14:39:18 +02:00
yuanrunsen e9e8be6cc0 Fix error config registration of elasticsearch
Configuration options must be registered before using them.
In impl_elasticsearch.py, using conf.database.es_index_name
or using conf.database.es_index_name are all wrong that will
lead the api server to be invalid.

Change-Id: I6b1364954c231a477d493d4a518c080f87058123
Signed-off-by: yuanrunsen <yuanrunsen@unitedstack.com>
2019-11-28 08:43:26 +00:00
zhurong 92a0a825e5 PDF documentation build
Change-Id: I7db6a34ba582c048c40c450453f239ada6260ac2
2019-09-19 22:39:38 -07:00
zhulingjie 789f7c3e16 Update json module to jsonutils
oslo project provide jsonutils, the others project use it
this PS to update the json moudule to oslo jsonutils.

Change-Id: I311d4f9dec7b685a5bccb9725de6010926375c7d
2019-06-03 11:13:54 +00:00
Tovin Seven 619b7e1ee0 Integrate OSprofiler in Panko
* Add osprofiler wsgi middleware. This middleware is used for 2 things:
  1) It checks that person who wants to trace is trusted and knows
     secret HMAC key.
  2) It starts tracing in case of proper trace headers
     and adds first wsgi trace point, with info about HTTP request

* Traces HTTP API calls
* Traces DB (SQLAlchemy) calls

Demo: https://tovin07.github.io/panko/openstack-event-list.html

HOW TO TEST?

1. Install devstack with panko as usual

2. Install osprofiler

    pip install osprofiler

3. Add these line to /etc/panko/panko.conf

   [profiler]
   enabled = true
   hmac_keys = SECRET_KEY
   connection_string = redis://localhost:6379 # example when using redis

4. Pass HMAC_KEYS to client commands
    - panko client with `--profile <HMAC_KEYS>`
    - openstack client with `--os-profiler <HMAC_KEYS>`

Output will look like this:

To display trace use the command:

  osprofiler trace show --html <TRACE_ID>

5. Use osprofiler to get the trace

    osprofiler trace show \
        --connection-string redis://localhost:6379 \
        --out out.html \
        --html <TRACE_ID>

6. Open that html file with browser and view the result

Change-Id: Ic934acbe1340a3e00361f2709f34725e0e4aa3ba
2019-04-12 02:18:28 +00:00
Pavlo Shchelokovskyy daa08ec939 Reraise last error when getting DB connection
currently when there is a problem with configuration, the logging is
insufficient, especially when running panko-dbsync command.

Change-Id: I22ef74eb45f324fc6e374c4a3e03fbe9d7268eed
2018-08-02 14:23:49 +00:00
Mehdi Abaakouk 61ae4a2cd3 storage: hide useless logs
Logging the sqlalchemy DuplicateEntry error message on each event
is useless. And people may though it's an error.

This change moves the log level to debug.

Change-Id: I86b64e5cf370386dab6f962b09029feeb35a9dbf
2018-05-22 08:06:28 +02:00
gord chung 52cea05031 pass empty url if missing
instead of raising AttributeError

Change-Id: I7f7ae280554c585aeca3d92b9d3ec5bea18e4ed0
2017-10-05 17:57:51 +00:00
Jenkins 86d2f605f0 Merge "sql: support bigint traits" 2017-08-30 09:13:22 +00:00
astacksu 99d591df95 Fix api's event listing query to sqlalchemy with non-admin user
Closes-Bug: #1710812

Original problem:

  Event storage backend is sqlalchemy(mariaDB).
  When listing events by:

         openstack event list [--limit n]
     or  ceilometer event-list [--limit n]

  using non-admin user, the number of events returned does not match the
  limit 'n'. It has much fewer events than it should have. Even when
  limit is not given, the default limit (100 if not changed) will apply
  and that the returned result is still wrong.

Problems in code:

  In the file 'panko/storage/impl_sqlalchemy.py
  The subquery for trait filtering(project_id, user_id mostly) which
  generated in function 'get_events' into variable 'trait_subq' (start
  around line 269) does not seem behave correctly.

  In the original code, the subquery is being wrapped into a deeper
  layered subquery when a new trait is applied. The resulting
  complicated subquery makes results have duplicate 'event_id's. And
  duplicate ids still count for the amount of the result, resulting in
  much fewer number of events than the one 'limit' flag sets.

Fixing:

  This part(line 269-299) which generates the subquery is modified.
  For each trait, the table the trait is in is adding to the 'from' part
  of the query. As for the 'where' section, the trait is filtered, and
  the event_id should be the same as other ones.

  The function at the beginning is changed from '_build_trait_query' to
  '_get_model_and_conditions' which used by the part mentioned above.

  'sqlalchemy.orm.aliased' is imported to aliase tables since the same
  table may be selected multiple times, and it is required to apply
  'aliased' to the table model before adding them to the query.

Test:

  $ tox -e py27-mysql

  The difference is at function 'test_get_event_multiple_trait_filter'
  in file '/tests/functional/storage/test_storage_scenarios.py'.
  The order of the traits to filter can affect how the original code
  produce the subquery, which is the cause of duplicate event_id.

Patch:

  1. Fix coding style according to Julien Danjou's suggestion.

  2. Add test code. Actually, modify existing one.

Change-Id: Ic303e4ed7af43c1d31559895c56a29b2c5ea85fc
2017-08-21 12:49:04 +08:00
gord chung fa8656ca7f sql: support bigint traits
add alembic and support bigint traits

Change-Id: I1fa3b5f9d72a4bc34b006648430c8399e9f3668e
Closes-Bug: #1644954
2017-07-28 13:01:11 +00:00
Jenkins ff94b1a188 Merge "deprecate hbase" 2017-06-27 01:59:31 +00:00
Luis Pigueiras fe7549adff Add url_prefix parameter in Elasticsearch connection
Forgot to include it in https://review.openstack.org/#/c/450204/
when I did the second patch

Change-Id: I57b920f77b8cd489fda13b8dbf8c219b888601d6
2017-06-16 11:28:36 +02:00
gord chung 6c14a69079 deprecate hbase
ain't nobody got time for this

Change-Id: I8b5220798738aa02e06615e1493744d644507609
2017-06-14 17:10:59 +00:00
Jenkins 2a596cb7aa Merge "pass only database options" 2017-05-30 22:04:06 +00:00
gord chung d63184a42a storage: Ensure pymysql is prefered
copy of Ifc6932701da647e50b7b8180372af1157d168793

Change-Id: I396674398d61599c0bf9e42077d877661a7d7405
2017-05-25 19:02:10 +00:00
gord chung 1fb31ad807 pass only database options
do not pass non-oslo.db options when initialising. it will throw
warnings saying it's unsupported

Change-Id: I72879785fb84a65caa725599b3ccdc1aa73022cb
2017-05-25 18:58:01 +00:00
loooosy 3084860863 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: I877d8897d3e314903e704073868aaa877eac8167
2017-04-08 22:14:11 +08:00
Jenkins aa089a0bf4 Merge "Add new connection parameters in ES" 2017-03-28 10:15:44 +00:00
Luis Pigueiras dafe861452 Add new connection parameters in ES
Allow to:
- Use ssl connection to the ES cluster
- Parametrize the index name (which was hardcoded to 'events')

Change-Id: I1c72ba6b4c216a5ab7fad10d53545d15f240a26d
2017-03-27 16:43:28 +02:00
Julien Danjou e4021dbeac sqlalchemy: use nested transaction when getting/creating event types
If adding the database fails, not using a nested transaction will make the
whole transaction passed from the caller fail. The code does not handle that at
all.

This switches to using a nested transaction, so only the insert is rolled-back
if it fails.

Change-Id: I5196147524e5fdd0d46d4c1995a8afb964ce3f6f
2017-03-22 14:00:39 +01:00
Hanxi Liu 2220ff70a0 storage: get database url in right order
event_connection has been deprecated, so we should get connection
from connection url by default.

Change-Id: I0daf73e7163ade7ce6540199525e694b8d574fb3
2017-02-10 22:10:17 +08:00
gord chung 97742e644d remove event_* prefixes
we don't need this.

Change-Id: Ia2008bb8de5335776b58b8e5e5f69f7ec88d30b9
2017-01-13 20:50:14 +00:00
gord chung 41f345f552 remove event redundancy
- we don't need to prefix 'event/storage' because that's all panko
does. cleanup inline with aodh.
- test_hbase_table_utils is not used anywhere and last reference
was from icehouse.
- drop a few places that use 'event_*' prefix since it wastes line
space

Change-Id: I348f5a3dfb59682589b4912eaed4e4b8abb15ebb
2017-01-13 09:03:48 -05:00
gord chung 4a498085c2 remove ceilometer/meter specific hbase code
we don't have metadata, meter or source concepts in events

Change-Id: Iabf9900d14fc3f7b7ca1a1918a18ef095fc12f22
2017-01-12 19:19:12 +00:00
“zhangshengping2012” a57db4e64a Replace all retrying with tenacity in Panko
Change-Id: I7e61fa4dad70801cdbc1f543fe18d7c1a64116b0
2016-12-08 23:08:38 +08:00
Julien Danjou 7170ce4d8a Bump hacking to 0.12
Change-Id: I36236b81c055a303587e4b587bf41c5c6d585cce
2016-11-07 22:39:43 +01:00
Jenkins 74fcb2519b Merge "Enable paginate query for event listing" 2016-10-05 13:25:01 +00:00
Amy Fong 272c872f2f Enable paginate query for event listing
sorting and marker options are enabled for event listing (for sqlalchemy only)
using oslob.db.

    sort -- list of sorting criteria. Each sorting option has to format
            <sort key>:<sort direction>

            Valid sort keys: message_id, generated
            Valid sort directions: asc (ascending), desc (descending)
                    This defaults to asc if unspecified

            If sort list is unspecified, this defaults to
            ['generated:asc', 'message_id:asc']

    marker -- If specified, assumed to be an integer and assumed to be the
              message id of the last object on the previous page of the results

limit is still available and supported for non sqlalchemy databases

Closes-bug: #1615699
Change-Id: I0441ca6283be5859c09c3d381ffbb52ca4a79eca
2016-10-04 14:06:01 -04:00
Cao Xuan Hoang e3dd93277d Docstrings should not start with a space
As per OpenStack Docstrings guide lines [1]:
[H401] Docstrings should not start with a space.

[1] http://docs.openstack.org/developer/hacking/#docstrings

trivialfix

Change-Id: I34129c85c16cf87afea104c31cea3c974aea725e
2016-09-27 12:44:11 +07:00
Hanxi 02d16e5f70 Base.Model not define __ne__() built-in function
Class base.Model defines __eq__() built-in function, but does
not define __ne__() built-in function, so self.assertEqual works
but self.assertNotEqual does not work at all in this test case in
python2. This patch fixes it.

Change-Id: I22e6b8e067638e148923e7a72aa8bfdc5f29b6df
Closes-Bug: #1586268
2016-09-14 06:34:09 +00:00
Julien Danjou 95abeb8b06 Stop relying on global CONF object
The conf object is now prepared on demand by panko.service.prepare_service.

Change-Id: I3526e73f8acbcb089d42850c0762305a08726db7
2016-06-27 17:03:38 +02:00
Julien Danjou a6db438577 mongodb: switch to retrying, stop using global conf
Change-Id: I79aac151c60c880699abba2a7f54cb89f189ad88
2016-06-27 17:03:38 +02:00
Julien Danjou 5c995c3924 storage: pass the conf object to drivers
Some storage drivers such as SQL need it.

Change-Id: I4ef122003d372976a4e401aee223e971133dd8f7
2016-06-27 17:03:38 +02:00
Julien Danjou d40c2a2867 tox: build all needed functional targets + fix compat with Gabbi >= 1.22 + fix raw type
Fix JSON SQL type to be Text, like it's actually in the old Ceilometer
migration script.

Change-Id: I647254d7b0e8f3c3983354a18e049ea633565187
2016-06-24 16:09:18 +02:00
Julien Danjou 3009be7ee7 Rename to Panko
Change-Id: I50b5f6c7b74a4431ccb7af271c11fe9c027f83ab
Signed-off-by: Julien Danjou <julien@danjou.info>
2016-06-14 17:00:22 +02:00