fix postgres module to use config.get - #70013
Conversation
|
@twangboy - With respect to the feedback on the previous MR: Please help me understand. Using However, as far as I can tell, what the postgres module really does is look for the psql binary on the system and execute it. As a result, I am unable to identify any configuration options that should have non- if user:
cmd += ["--username", user]
if host:
cmd += ["--host", host]
if port:
cmd += ["--port", str(port)]
if not maintenance_db:
maintenance_db = "postgres"
The above code block seems to support that every config option ought to be able to accept The only way I can think of to make sense, is to make the defaults of config values to return |
2a64989 to
27262a9
Compare
|
I think you're right. The connection logic in postgres.py checks for Falsey values to conditionally build CLI flags so passing The key reason we need Many deployments currently set flat keys as documented in the module header: postgres.host: 'localhost'
postgres.user: 'salt_admin'
postgres.bins_dir: '/usr/pgsql-14/bin'Because Using __salt__["config.get"]("postgres.user", delimiter=".")allows Salt to evaluate both flat Looks like there's a small typo in the parameter name. # Current (typo in parameter name):
pg_bin_dir = __salt__["config.get"]("postgres.bins_dir", delimeter='.')
# Needs to be:
pg_bin_dir = __salt__["config.get"]("postgres.bins_dir", delimiter='.')Additionally, this will need a changelog and some tests written. Thank you for rebasing on 3006.x. |
757ddbe to
df472d7
Compare
|
@twangboy Thank you for your explanation. My spelling isn't the best, I did notice the mispelling, and I thought that I pushed it forward, but I'm working with several different machines, because I can't get the pre-commits to work on my mac (I think I would like to try to open with an issue and pr for that as well if it is welcome, but one thing at a time). I see what you're saying about the yaml now, I thought that was another way of nesting keys in yaml, but now that you have said something I'm able to see that I was wrong. Thanks for helping me out. I have pushed the fix to the typo with delimiter. I'm not sure about the changelog, but I could work on testing if I could get a tad bit of direction with the changelog and tests. The contribution guide says
However, under salt there is no changelog, except for at the root of the project, so I've put it there (I think that's right, just want to bring up my confusion). I think you might need to give me a bit until I can understand what your testing process is. I'm going to read: https://docs.saltproject.io/en/master/topics/tutorials/writing_tests.html. Is that a the best documentation on your expectations about tests? Would you like me to change this PR to WIP until the tests are written? (Honestly, I was kind of hoping that some tests for this was already written but I'm happy to help fill in that gap if there is an opportunity for that). |
45c07d9 to
962a5b4
Compare
What does this PR do?
Modifies the postgres execution module to respect the configuration set by changing all calls from
config.optiontoconfig.getand setting the string delimiters to colons.As noted in the related issue I opened:
It seems like
config.optionis just the wrong function to use andconfig.getis the correct one.Before this fix:
After:
What issues does this PR fix or reference?
Fixes #69971
Previous Behavior
postgres module was not respecting the configuration set in either the pillars or minion configuration file.
New Behavior
postgres module now respects configuration values.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes