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

Cleanup useless $connect_setting validation #1487

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

bastelfreak
Copy link
Collaborator

In the past we checked if $connect_setting isn't undef. That is not required because the default is {} and the Datatype is hash. Undef isn't allowed.

Summary

Provide a detailed description of all the changes present in this pull request.

Additional Context

Add any additional context about the problem here.

  • Root cause and the steps to reproduce. (If applicable)
  • Thought process behind the implementation.

Related Issues (if any)

Mention any related issues or pull requests.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

Comment on lines +65 to 71
if $port {
$port_override = $port
} elsif $connect_settings != undef and 'PGPORT' in $connect_settings {
} elsif 'PGPORT' in $connect_settings {
$port_override = undef
} else {
$port_override = $postgresql::server::port
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the whole block doesn't make sense? Port is always set and cannot be undef. so $port_override is always set to $port? I don't thinky anybody uses $connect_settings. The whole setup seems broken?

@@ -178,11 +178,11 @@
environment => 'PGOPTIONS=--client-min-messages=error',
}

if($role != undef and defined(Postgresql::Server::Role[$role])) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

$role cannot be undef

Postgresql::Server::Role[$role] -> Postgresql_psql["default_privileges:${name}"]
}

if($db != undef and defined(Postgresql::Server::Database[$db])) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

$db cannot be undef.

Comment on lines -80 to +82
if $port != undef {
if $port {
$port_override = $port
} elsif $connect_settings != undef and 'PGPORT' in $connect_settings {
} elsif 'PGPORT' in $connect_settings {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here it makes sense because $port is undef by default

Comment on lines -80 to 83
if $port != undef {
if $port {
$port_override = $port
} elsif $connect_settings != undef and 'PGPORT' in $connect_settings {
$port_override = undef
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whole block doesn't make sense because $port isn't undef?

In the past we checked if $connect_setting isn't undef. That is not
required because the default is {} and the Datatype is hash. Undef isn't
allowed.
@bastelfreak
Copy link
Collaborator Author

I think the changes in this PR don't change the current behaviour so they should be safe to merge. But I think they point out the connect_setting implementation is currently broken, at least in some classes.

@@ -53,17 +53,17 @@
#
# Port, order of precedence: $port parameter, $connect_settings[PGPORT], $postgresql::server::port
#
if $port != undef {
if $port {
Copy link
Contributor

@Ramesh7 Ramesh7 Aug 31, 2023

Choose a reason for hiding this comment

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

Bit of confusing for me due to the priority changing in each file, not sure its expected.
Coz here we are giving high priority to $port but in manifests/server/reassign_owned_by.pp we are giving high priority to $connect_settings.
Just thinking if we can make identical across the board?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case, the priority doesn't change. $port is still undef by default. In some classes the logic seems to be broken because $port doesn't default to undef, but that problem exists on the main branch already.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is fine to merge because it only simplifies the code, it doesn't change the logic. but the logic is broken and should probably be checked in a dedicated issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

#1469 was aimed at making it more consistent. I haven't checked back on the most recent implementation, but you're right that it is inconsistent between files.

Copy link
Contributor

@Ramesh7 Ramesh7 left a comment

Choose a reason for hiding this comment

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

except minor comments LGTM

@bastelfreak bastelfreak merged commit 934c5bb into puppetlabs:main Aug 31, 2023
37 checks passed
@bastelfreak bastelfreak deleted the connection branch August 31, 2023 09:47
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.

5 participants