-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix privilege changing everytime #438
Fix privilege changing everytime #438
Conversation
Codecov Report
@@ Coverage Diff @@
## main #438 +/- ##
=======================================
Coverage 77.82% 77.83%
=======================================
Files 27 27
Lines 2327 2328 +1
Branches 562 562
=======================================
+ Hits 1811 1812 +1
Misses 356 356
Partials 160 160
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@rsicart thanks for the fix!
UPDATE: sorry, didn't notice that it's a draft |
@Andersson007 ready for review :) all reviewers are welcome! |
BTW I'll add the changelog fragment this morning... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rsicart great job, it's cool to see changes covered with integration and units!
cc @betanummeric @laurent-indermuehle could you also please take a look? |
I'm very happy with this contribution which removes multiple "when: mysql... when: mariadb..." conditions. And a bug! But the method privileges_equal(before_privs, after_privs) is only a comparison (==). And the only thing the unit test tests is the Python comparison operator. Which we should not test at our level. What if future version of MySQL and MariaDB changes the way they handle privileges? We will have new bugs without knowing. I would prefer to replace the call to privileges_equal with a simple == in the module, remove the unit test and the method. Then replace this with integration tests that validate that grants are added, revoked, entirely, partially and with all supported database engine. |
Yes, before beginning this PR I thought I'd need a more complex function, comparing key by key, list by list, or something like that. Finally it seems that a comparison makes it.
That's what happened with 'ALL PRIVILEGES' translation.
I can do that if you prefer, it makes sense to me also.
I think there's already some tests for privilege replace, append and subtract. Don't they cover already what you comment? Perhaps that should be a new issue to improve integration test suite. |
My bad, I didn't checked the 21 (!!!) files inside tests/integration/targets/test_mysql_user/tasks. lgtm! Thanks for the modifications! |
I like the validation by comparing the existing privileges before and after the grant/revoke. 👍 For the record, MariaDB is also very chaotic when it comes to privileges (see https://mariadb.com/kb/en/grant/):
But implementing special logic for this mess would only make sense to avoid an unwanted revocation, like we did in PR #434 for the |
Thank you @Andersson007 @laurent-indermuehle @betanummeric for reviewing! :) |
@rsicart thanks for the contribution! |
I'm not sure @Andersson007, this PR fixes code introduced by #333 which was not backported. |
@rsicart ah, ok, doesn't need then, thanks for the info |
I tried to patch stable-2 with your changes and all integrations tests pass. But there is less tests in stable-2. I would not be confident to backport this. |
stable-1 subtracts existing from requested privileges and grants those assuming a change, so in theory it is affected by the false change bug as well. But I would say it's too much effort to backport. |
@laurent-indermuehle if the related code was introduced in #333, we must not backport the fix as it relates to a new feature introduced in 3.. (we don't backport new features, so the related code isn't present in stable-2 and stable-1 |
i wouldn't touch the other branches if it's not impossible to backport it with just |
sorry, forgot to draft a release for 3.5.0 last time, just did it. |
I'll do it. |
SUMMARY
Compare privileges from before and after manipulation to determine if a change was made to user privileges.
For the moment,
privileges_equal()
function is very naive. We'll see if we need to do a deeper comparison or use an already existing tool for the job (f.e. deepdiff).Fixes #77
See #77 for more details.
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
mysql_user