-
Notifications
You must be signed in to change notification settings - Fork 613
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
Prefer $connect_settings over explicit parameters #1498
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
250a589
to
03dd114
Compare
I raised this to explain the current situation. This PR doesn't solve all the problems. If we agree on preferring Edit: I updated all related code pieces. |
6c22012
to
7a579ae
Compare
SimonHoenscheid
previously approved these changes
Aug 31, 2023
09289b8
to
7b251da
Compare
This is the outcome of a large refactoring in puppetlabs#1450 and discussions on IRC and slack. We noticed that the behaviour of `$connect_settings` is currently inconsistent. Sometimes it's preferred over explicity parameters, sometimes not. Reminder: The idea of `$connect_settings` is to provide a hash with environment variable to tell puppet to manage a remote database instead of a local instance. One example is: https://github.com/puppetlabs/puppetlabs-postgresql/blob/93386b48861ff41d5f47033afee592e0506526c5/manifests/server/grant.pp#L80-L86 ``` if $port { $port_override = $port } elsif 'PGPORT' in $connect_settings { $port_override = undef } else { $port_override = $postgresql::server::port } ``` Here the local $port parameter is preferred over `$connect_settings`. The problem is that we now cannot set a default in the resource for `$port`. The default is hardcoded to `$postgresql::server::port`. This becomes. Other classes handle it in a different way: https://github.com/puppetlabs/puppetlabs-postgresql/blob/93386b48861ff41d5f47033afee592e0506526c5/manifests/server/database.pp#L41-L46 ``` if 'PGPORT' in $connect_settings { $port_override = undef } else { $port_override = $port } ``` Here `$connct_settings` is checked first. It defaults to an empty hash. If `PGPORT` isn't in it, `$port` is used. The logic is shorter and enables us to expose $port as a parameter with a default value. With this approach users can decide if they pass `$port` or `$connect_settings`. At the moment the remote database support is broken because the logic to parse `$connect_settings` isn't consistent. The goal of this PR is to unify the logic and prefer `$connect_settings` if it's provided by the user.
7b251da
to
1a4125e
Compare
Ramesh7
reviewed
Sep 5, 2023
Ramesh7
approved these changes
Sep 5, 2023
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.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the outcome of a large refactoring in #1450 and discussions on IRC and slack. We noticed that the behaviour of
$connect_settings
is currently inconsistent. Sometimes it's preferred over explicity parameters, sometimes not.Reminder: The idea of
$connect_settings
is to provide a hash with environment variable to tell puppet to manage a remote database instead of a local instance.One example is:
puppetlabs-postgresql/manifests/server/grant.pp
Lines 80 to 86 in 93386b4
Here the local $port parameter is preferred over
$connect_settings
. The problem is that we now cannot set a default in the resource for$port
. The default is hardcoded to$postgresql::server::port
. This becomes. Other classes handle it in a different way:puppetlabs-postgresql/manifests/server/database.pp
Lines 41 to 46 in 93386b4
Here
$connct_settings
is checked first. It defaults to an empty hash.If
PGPORT
isn't in it,$port
is used. The logic is shorter andenables us to expose $port as a parameter with a default value. With
this approach users can decide if they pass
$port
or$connect_settings
.At the moment the remote database support is broken because the logic to
parse
$connect_settings
isn't consistent. The goal of this PR is tounify the logic and prefer
$connect_settings
if it's provided by theuser.