Fix postgres execution not respecting configuration values - #69973
Fix postgres execution not respecting configuration values#69973nicholas-rees wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Because config.option("postgres.bins_dir") uses . as a flat key lookup, switching to config.get("postgres:bins_dir") without specifying delimiter='.' means Salt will no longer match the exact configuration keys shown in its own module documentation.
All config.get calls should use delimiter="." to avoid breaking existing configs.
Also, when switching to config.get, any lookup for an option that requires a non-None fallback (like a default port 5432 or default database "postgres") should explicitly pass default=.... Otherwise, missing config keys silently return None into functions that might not be expecting None.
And yes, this should go onto 3006.x
| Helper function to locate various psql related binaries | ||
| """ | ||
| pg_bin_dir = __salt__["config.option"]("postgres.bins_dir") | ||
| pg_bin_dir = __salt__["config.get"]("postgres:bins_dir") |
There was a problem hiding this comment.
Delimiter Syntax Change (postgres.bins_dir vs postgres:bins_dir)
- Switching from
config.optiontoconfig.get` changes the default string delimiter from.to:``. - If existing users have keys configured as
postgres.bins_dir,postgres.host, orpostgres.userin their minion configs,config.get("postgres:bins_dir")will fail to find them unless thedelimiter='.'argument is passed or the lookups are explicitly structured to support legacy dot notation. - Standard Salt convention for
config.getlookup with dot-separated string keys requires settingdelimiter='.':
__salt__["config.get"]("postgres.bins_dir", delimiter=".")| "timeout": __salt__["config.get"]( | ||
| "postgres:timeout", default=_DEFAULT_COMMAND_TIMEOUT_SECS |
There was a problem hiding this comment.
Same thing here, pass delimiter="."
| timeout=__salt__["config.get"]( | ||
| "postgres:timeout", default=_DEFAULT_COMMAND_TIMEOUT_SECS |
|
Because I had to change the branch to 3006.x, I had to either force push, rename, or delete the previous branch in order to be sure the commits would line up. When doing so, that caused this PR to be closed. You can find the new MR at #70013. |
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:
I do not know if this should go in the 3006.x. I sort of suspect that it should but I have not tested this at all on 3006.x so I have made this PR. If you would like to change it to 3006.x let me know and I can do that work.
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