Commit Graph

109 Commits

Author SHA1 Message Date
Matthias Runge 92be85c4ca Remove leftovers of retirement
Change-Id: I5acab95813ac3d0604f73c377bf111f423a008bc
2021-07-09 15:21:47 +02:00
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
Zuul 053b147b48 Merge "[goal] Deprecate the JSON formatted policy file" 2021-05-17 11:10:59 +00:00
likui 9f190a5cea Replace getargspec with getfullargspec
inspect.getargspec() is deprecated since py3

[1] https://docs.python.org/3/library/inspect.html#inspect.getargspec

Change-Id: I1a838b0e0ac9b582c4176c43962904ab31b6d5d9
2021-05-11 16:24:16 +08:00
Ghanshyam Mann 6da394a59a [goal] Deprecate the JSON formatted policy file
As per the community goal of migrating the policy file
the format from JSON to YAML[1], we need to do two things:

1. Change the default value of '[oslo_policy] policy_file''
config option from 'policy.json' to 'policy.yaml' with
upgrade checks.

2. Deprecate the JSON formatted policy file on the project side
via warning in doc and releasenotes.

Also replace policy.json to policy.yaml ref from doc and tests.

[1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Change-Id: Ie6e22b0b47c5148290f7b76c95967cd9a343343c
2021-02-11 12:40:40 -06:00
Zuul 3054d7784e Merge "Remove six" 2021-01-25 08:33:20 +00: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
Lance Bragstad 6195c9a06d Implement secure RBAC for segregation and telemetry policies
This commit updates the policies for all policies in panko to support
enhanced token scope checking and default roles, but implementing
support for a reader role for read-only APIs.

This is part of a broader change to provide a more consistent and secure
authorization experience for operators and users across OpenStack.

Change-Id: Ia0daee7d909f31e7f8f9e75fa52dca9254441559
2020-12-01 14:37:26 +00:00
Lance Bragstad 12c41a0a73 Add a system-reader check string to base.py
This commit adds a new constant to base.py that models a common persona
being implemented across OpenStack called system-reader. We can use this
persona in future patches to update the default policies for the
appropriate APIs.

Change-Id: I12074fe328db71895bbdfda3c9e7c56cc6b6f40d
2020-12-01 14:35:41 +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
Sean McGinnis 36668ecfad
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: I92f240b2b2fbb8a0a7ac188ff9bed8b0d11209b3
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 11:57:05 -05: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
Zuul 902ad62e83 Merge "Integrate OSprofiler in Panko" 2019-04-12 08:21:41 +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
OpenStack Proposal Bot 03fdaded5b Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I05db916d0cdee6b29be890814a9955ba014e8076
Depends-On: I15c2c4cf795ec1b92d25858c65e58b82a017b1e6
2019-04-11 14:53:36 +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 352d89833c Don't use deprecated publisher anymore
Depends-On: I9bb2f392bcdd5d920a8f0db883766e5439d7de73
Change-Id: I27af2ebccbc2bbccfcc2235ac5bd49b11e8690ed
2018-07-10 15:52:00 +02:00
OpenStack Proposal Bot f1bcceaaa3 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I097bfe64c36f734b3f27260b0b5459387e92ba3b
2018-05-23 07:08:56 +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
Julien Danjou 14a10f9a73 Revert "Operator for start/end_timestamp changes to 'eq'"
This reverts commit b540674a84.

This changes is wrong in the sense as it removes the ability to filter via ge/le the start and end timestamps.

Change-Id: I0c82917a6fd6795266e34b4d151faf13f43ab5bb
2018-04-18 14:08:52 +00:00
OpenStack Proposal Bot 3e1171f558 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I7208cdbaa9b9d350ccda3affe028876fe120258a
2018-03-01 06:04:46 +00:00
Zuul d894e793f6 Merge "Remove jsonutils usage" 2017-12-13 12:41:37 +00:00
Chandan Kumar e8b1378c0f Removed dummy intree panko tempest plugin
* Intree panko tempest plugin does not contains any tempest tests
  and has just dummy tempest plugin skeletion, so it is better to
  remove from the project. If in future new panko tempest tests
  will be written, will go to a new repo where all the telemetry
  tests will resides.

Change-Id: I4f56bdac3ddd7b55ae791c9e6aafb78bc5f6e14b
2017-12-04 14:01:39 +00:00
Zuul 48b3c63cb5 Merge "Move default policies into code" 2017-11-28 20:19:08 +00:00
Julien Danjou 70219e3188 Remove jsonutils usage
Panko does not depends on oslo.serialization while it is using it. However,
since it does not really need it, let's use the regular json attribute anyway.

Change-Id: I63e5927c625d0a080bd6a9ea77ff939253039d5e
2017-11-22 23:39:28 +01:00
Lance Bragstad 52417d4ab8 Move default policies into code
This is part of a community effort to provide better user experience
for those having to maintain RBAC policy. More information on this
effort can be found below:

  https://governance.openstack.org/tc/goals/queens/policy-in-code.html

bp policy-and-docs-in-code
Co-authored-By: Hieu LE <hieulq@vn.fujitsu.com>
Change-Id: I9bad70abcf5543c3e5e5da25c56c408ee3ff0346
2017-11-08 04:35:54 +00:00
Zuul f4f1a4069f Merge "Support admin to get all events" 2017-11-06 08:36:43 +00:00
zhang-shaoman f7d5e0564a Support admin to get all events
Currently admin can only get project_id consistent events, while
sometimes admin need to get all the events, so add a parameter
"all_tenants" for the api to achieve this purpose.

Change-Id: I7c479a63c41d4b0fbf645bdb1b70f0259b0cb859
2017-11-03 11:19:42 +08:00
Zuul f98d6476c7 Merge "Remove deprecated Panko dispatcher" 2017-10-23 13:43:42 +00:00
Nguyen Van Trung ec59fc62e3 Use generic user for both zuul v2 and v3
Zuul v2 uses 'jenkins' as user, but Zuul v3 uses 'zuul'.
Using $USER solves it for both cases.

Change-Id: I4848c16a40dd9c0e25f916b0e8afec9bde0c3fc7
2017-10-20 04:10:03 +00:00
gord chung 52cea05031 pass empty url if missing
instead of raising AttributeError

Change-Id: I7f7ae280554c585aeca3d92b9d3ec5bea18e4ed0
2017-10-05 17:57:51 +00:00
OpenStack Proposal Bot 1f74bbd7b6 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I64dfc3673e34428ef4cb5ba40fdaf1ce456763c1
2017-10-04 18:08:35 +00:00
Julien Danjou 2170159d2e Remove deprecated Panko dispatcher
Change-Id: Ibc6e6b31de87e61ff815499f226538db710d45d3
2017-09-27 09:53:28 +02:00
astacksu b540674a84 Operator for start/end_timestamp changes to 'eq'
start/end_timestamp originally are associated with op 'ge' and 'le'.
Changing them to 'eq' fixes the bug and the usage will make more sense.

Related review: https://review.openstack.org/#/c/495763
Change-Id: Ia94a499f9340102553863db48dccb96bea92ea78
Closes-Bug: #1711997
2017-09-15 09:05:07 +08:00
Jenkins 86d2f605f0 Merge "sql: support bigint traits" 2017-08-30 09:13:22 +00:00
Jenkins eb504b8a13 Merge "Fix api's event listing query to sqlalchemy with non-admin user" 2017-08-28 23:54:09 +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
shangxiaobj eea3eef269 Fix typos and replace http with https for doc links
1) Fix typos found in panko
2) Use https instead of http for docs links in panko

Change-Id: Iccc8e0c612d6681bf39dec6b7b79b5ad30a23eca
2017-08-17 23:52:20 -07: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 868dddf2b6 Merge "Add field description" 2017-07-25 17:44:56 +00:00
Hangdong Zhang 16d122a5e8 Update the documentation link for doc migration
Change-Id: Iac3e6c11480ca0a0dccfd90d722d905f2e4911e5
BTW: Do some optimization as well (http -> https)
2017-07-24 11:04:31 +08:00
OpenStack Proposal Bot bc3aa2ecb7 Imported Translations from Zanata
For more information about this automatic import see:
http://docs.openstack.org/developer/i18n/reviewing-translation-import.html

Change-Id: I0c118b75ba899886793caa10fc88733bc0c475af
2017-07-18 08:12:47 +00:00
Boris Bobrov c677b23960 Add field description
It was not documented how to filter based on `generated` field.

Added a field and a description for it so that it gets rendered in the
docs.

Change-Id: I3f4929ce4876015817e230d8855dbccbd5d34e27
2017-06-30 15:45:07 +03: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