panko-api --limit flag misbehaved when using non-admin user
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Panko |
Fix Released
|
Undecided
|
SU, HAO-CHEN |
Bug Description
OS: Ubuntu 16.04.3
Openstack vesion: Ocata
Panko version: stable/ocata, master(Jul 28, 2017)
Event storage backends: MariaDB
Problem:
$ ceilometer event-list --limit 5
$ openstack event list --limit 5
both commands above with environment variables:
export OS_PROJECT_
export OS_USERNAME=demo
gave back only one event.
I had checked in the database that the events are there and if the number
given to limit flag was
large enough, more events would show up.
Self Examination:
First, adding 'admin' user to the 'demo' project and using environment
variables:
export OS_PROJECT_
export OS_USERNAME=admin
gave back correct results with 5 events.
So, I went into source files and found that the problem might reside in
the file:
panko/
I checked the mysql query spawn in the function 'get_event'.
when using 'admin' as the user, the query is:
SELECT event.id AS event_id
FROM event JOIN event_type ON event_type.id = event.event_type_id
WHERE EXISTS (SELECT *
FROM (SELECT anon_2.
FROM (SELECT trait_text.event_id AS trait_text_event_id
FROM trait_text
WHERE NOT (EXISTS (SELECT *
FROM (SELECT trait_text.event_id AS event_id
FROM trait_text
WHERE trait_text.key = :key_1) AS anon_3
WHERE trait_text.event_id = anon_3.event_id)) UNION
SELECT trait_text.event_id AS trait_text_event_id
FROM trait_text, event
WHERE trait_text.key = :key_2 AND trait_text.value = :value_1
AND event.id = trait_text.
WHERE event.id = anon_1.
event.
LIMIT :param_1
when using 'demo' as the user, the query is:
SELECT event.id AS event_id
FROM event JOIN event_type ON event_type.id = event.event_type_id JOIN
(SELECT trait_text.event_id AS ev_id
FROM trait_text, (SELECT trait_text.event_id AS ev_id
FROM trait_text
WHERE trait_text.key = :key_1 AND trait_text.value = :value_1)
AS anon_2, (SELECT trait_text.event_id AS ev_id
FROM trait_text
WHERE trait_text.key = :key_2 AND trait_text.value = :value_2) AS anon_3
WHERE trait_text.key = :key_1 AND trait_text.value = :value_1 AND
anon_2.ev_id = anon_3.ev_id)
AS anon_1 ON anon_1.ev_id = event.id ORDER BY event.generated ASC,
event.
LIMIT :param_1
I execute the query directly in MariaDB CLI, and get back list with tons of
duplicate event IDs.
So I simply put the keyword 'DISTINCT' after the first 'SELECT':
SELECT DISTINCT event.id AS event_id
then the command gave back the correct result with 5 events.
Therefore, I'm guessing that the problem resides between line 292-307 of
the file.
( https:/
This part is what makes two queries using user 'admin and 'demo' different.
description: | updated |
Changed in panko: | |
status: | New → Confirmed |
assignee: | nobody → SU, HAO-CHEN (astacksu) |
Changed in panko: | |
status: | Confirmed → In Progress |
I have tried to modify the code in this file.
Currently I find it working correctly.