mysql root enable reports the user as 'root' instead of context.user

Bug #1546372 reported by Craig Vyvial
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
Fix Released
Low
Zhao Chao

Bug Description

I noticed some odd entries in the root history table when working on the pxc root enable call. Where some entries said it was 'root' that enabled root on the instance. This should be the id of the user that called the api to enable root.

Here is a list that i saw in the table.

mysql> select * from root_enabled_history;
+--------------------------------------+----------------------------------+---------------------+
| id | user | created |
+--------------------------------------+----------------------------------+---------------------+
| 2e9ef51a-85d7-4131-8333-520b125d4d3f | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 02:50:31 |
| 43578dab-863b-4360-abc2-6582eb1ca5fc | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 15:05:26 |
| 4d75fac2-19bf-4ae9-9bc2-2a33b700b6cd | root | 2016-02-06 19:31:12 |
| 5e156f99-f951-43aa-ba12-0765f4ba4af4 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 19:36:21 |
| 7603ef71-3054-49b3-9e6d-fc2e7d2d46b0 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 02:43:46 |
| 7c782a70-6db1-4091-bdf3-2bc9fd0cd2c5 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 19:36:21 |
| 81b07317-3ada-4b51-909d-d379236360f2 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 02:50:31 |
| b4a84b61-db39-4c12-a335-d06c28903c0b | root | 2016-02-06 02:45:56 |
| bd03733f-d715-47d7-b9a4-bb3f3c9a59c3 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 02:50:31 |
| bfe12a82-000b-4c9e-bd80-bbbc3139a124 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 15:13:04 |
| d1598059-5328-4524-ada6-4b55924a4db2 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 15:13:04 |
| d69c1465-b16e-4dbf-81c4-3a666243da38 | root | 2016-02-06 15:07:36 |
| d93d35b5-944f-4839-a299-f2b98f9b3d34 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 15:13:04 |
| e45a7d36-ee82-401e-995a-1daae6c7d61f | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 19:36:21 |
| e5492ed8-3176-4ca9-9cc9-aa38d878ae40 | 43a316dc327543db8fc21c3b1e09ede7 | 2016-02-06 19:29:03 |
+--------------------------------------+----------------------------------+---------------------+

https://github.com/openstack/trove/blob/master/trove/guestagent/datastore/mysql_common/manager.py#L232
Looks like the user here is hard-coded to 'root'. This should instead be context.user.

Although i'm not sure if context has the user attribute available here maybe that is why this is hard-coded currently.

Revision history for this message
Petr Malik (pmalik) wrote :

I think it is related: https://bugs.launchpad.net/trove/+bug/1532583

I had an idea we would be getting it from the models. The root user models define it already.
We just need a base method 'get_root_user' implemented by derived classes, which would return the appropriate model user.

Amrith Kumar (amrith)
Changed in trove:
milestone: mitaka-3 → mitaka-rc1
Amrith Kumar (amrith)
Changed in trove:
milestone: mitaka-rc1 → next
Revision history for this message
Manoj Kumar (manojnkumar) wrote :

Luke: Can you confirm whether Petr's fix resolves this issue as well?

Changed in trove:
assignee: nobody → Luke Browning (lukebrowning-y)
Zhao Chao (zhaochao1984)
Changed in trove:
assignee: Luke Browning (lukebrowning-y) → Zhao Chao (zhaochao1984)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to trove (master)

Fix proposed to branch: master
Review: https://review.openstack.org/541630

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to trove (master)

Reviewed: https://review.openstack.org/541630
Committed: https://git.openstack.org/cgit/openstack/trove/commit/?id=3b726f3013b0ba2a9f86b5b65278fadb981335cf
Submitter: Zuul
Branch: master

commit 3b726f3013b0ba2a9f86b5b65278fadb981335cf
Author: Zhao Chao <email address hidden>
Date: Wed Feb 7 15:37:30 2018 +0800

    report_root should always use context.user

    The RootHistory intends to record by whom and when the root user of the
    underlying datastore backend was enabled. So the "user" column should
    always be set to the context user, not the actual root user in the
    database. But report_root(and report_root_enabled in
    taskmanager.models) use the database user instead, this is not correct,
    This patch will fix.

    Also remove the "user" argument from Root.create() and
    HistoryRoot.create() because the context is already passed in as an
    argument when these methods are called.

    Closes-Bug: #1546372
    Change-Id: I3b4c8ee56c7e0876fb384f0c5841d2d391bd555d
    Signed-off-by: Zhao Chao <email address hidden>

Changed in trove:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/trove 10.0.0.0b1

This issue was fixed in the openstack/trove 10.0.0.0b1 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.