Skip to content

Only require password when used #1356

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

Merged
merged 1 commit into from
Aug 23, 2022

Conversation

arjenz
Copy link
Contributor

@arjenz arjenz commented Aug 9, 2022

If the if in line 39 evaluates to false, the user has been created
elsewhere, and we don't actually use (and thus need) password in
postgresql::server::db class.

@arjenz arjenz requested a review from a team as a code owner August 9, 2022 10:09
@puppet-community-rangefinder
Copy link

postgresql::server::db is a type

Breaking changes to this file WILL impact these 37 modules (exact match):
Breaking changes to this file MAY impact these 20 modules (near match):

This module is declared in 70 of 579 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about this use case. If you already define the user elsewhere, can't you simply use postgresql::server::database in the later places? What additional benefit is there in this defined type?

I see a tablespace relation, which is also in postgresql::server::database.

Then there is a GRANT. That isn't in postgresql::server::database, except for an owner. AFAIK that already implies all privileges so the only edge case is if you want that grant.

Am I missing anything?

@arjenz
Copy link
Contributor Author

arjenz commented Aug 9, 2022

Well the major use case from my end is "this is how we happen to use it, and it stopped working when d878d13#diff-09acae987abfb6f2de2796ebbbcee8911d8326cf762451972538f4f78984f35c was introduced".
Before that commit setting it to undef was fine, but afterwards not anymore.
Looking just at the code in this class, without taking global context into perspective this solution kind of makes sense. "Why require data when it's not actually used or needed for this class".

@arjenz
Copy link
Contributor Author

arjenz commented Aug 9, 2022

Oh, and right now, as a workaround, we're passing around password: 'unused' in hiera, since the value gets ignored anyway, so I feel solving this in the code is a bit more elegant :)

Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly because it makes the code (even more) compile order dependent. If the inclusion happens in another order, it may fail because no password is provided. Then again, you could already have code where there are 2 different passwords specified and the real password used ends up being determined by the compile order.

Now looking deeper, I see postgresql::server::role can create a user without a password. So I think this is valid if you drop the fail() part. That should then also be reflected in the @param tags.

If the if in line 39 evaluates to false, the user has been created
elsewhere, and we don't actually use (and thus need) password in
`postgresql::server::db` class.
@arjenz
Copy link
Contributor Author

arjenz commented Aug 9, 2022

Done :)

@ekohl
Copy link
Collaborator

ekohl commented Aug 9, 2022

Did you forget to push?

@arjenz arjenz force-pushed the allow_undef_password branch from 90e1522 to 4812333 Compare August 9, 2022 14:02
@arjenz
Copy link
Contributor Author

arjenz commented Aug 9, 2022

Did you forget to push?

Yes, yes I did :)

@ekohl ekohl added the bugfix label Aug 9, 2022
Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@david22swan this would have been nice to get in the release. However, I can't merge it because of a failed test.

Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Will get it merged in now

@david22swan david22swan merged commit 79bec28 into puppetlabs:main Aug 23, 2022
@arjenz arjenz deleted the allow_undef_password branch August 24, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants