Skip to content
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

Fixes edge-case with dropping pre-existing users with grants #779

Merged
merged 1 commit into from
Jan 15, 2016

Conversation

jmcclell
Copy link
Contributor

If a user exists in the database upon first Puppet run (for example, in the case of loading a database snapshot) and the run sets that user's :ensure attribute to 'absent', the mysql_grant provider will throw an error when the dependency chain causes it to try to destroy the grants associated with that user because the DROP statement from the mysql_user provider already removed the grants. To fix, we must check if the user exists before revoking the grants.

@jmcclell
Copy link
Contributor Author

This is potentially inefficient compared to, perhaps, catching the raised error and rescuing it if it matches a particular error pattern, though that feels a bit dirty and it doesn't seem like grants get dropped very often in the vast majority of use cases. Thoughts?

@igalic
Copy link
Contributor

igalic commented Nov 17, 2015

@jmcclell is there any way to (acceptance) test for this?

@jmcclell
Copy link
Contributor Author

Without a full integration test (actually having a running mysql with the proper starting condition) I don't know how one could model a test. My ruby-foo isn't very strong, either, I'm afraid.

@jonnytdevops
Copy link
Contributor

@jmcclell This actually looks good to me, and personally, I'd be happy enough if the current grant destroy tests still pass.

It would be appreciated if you could squash your commits though.

Thanks!

If a user exists in the database upon first Puppet run (for example, in the case of loading a database snapshot) and the run sets that user's :ensure attribute to 'absent', the mysql_grant provider will throw an error when the dependency chain causes it to try to destroy the grants associated with that user because the DROP statement from the mysql_user provider already removed the grants. To fix, we must check if the user exists before revoking the grants.
@jmcclell
Copy link
Contributor Author

Done.

igalic added a commit that referenced this pull request Jan 15, 2016
Fixes edge-case with dropping pre-existing users with grants
@igalic igalic merged commit 23672ca into puppetlabs:master Jan 15, 2016
@igalic
Copy link
Contributor

igalic commented Jan 15, 2016

thanks @jmcclell & @jonnytpuppet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants