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

Fix scope of disable_maintenance param #73

Merged
merged 2 commits into from
Jun 30, 2021

Conversation

m0dular
Copy link
Contributor

@m0dular m0dular commented Jun 28, 2021

No description provided.

@m0dular m0dular requested a review from a team as a code owner June 28, 2021 15:11
@puppet-community-rangefinder
Copy link

pe_databases is a class

that may have no external impact to Forge modules.

This module is declared in 0 of 576 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.

@MartyEwings MartyEwings linked an issue Jun 28, 2021 that may be closed by this pull request
@m0dular
Copy link
Contributor Author

m0dular commented Jun 28, 2021

Gave it the ol' "Works on my box" test 👍

@@ -30,7 +30,7 @@
if $facts.dig('pe_databases', 'have_systemd') {
if $manage_database_maintenance and (versioncmp('2019.0.2', $facts['pe_server_version']) <= 0) {
class {'pe_databases::pg_repack':
disable_maintenance => lookup('pe_databases::maintenance::disable_maintenance', {'default_value' => false}),
disable_maintenance => lookup('pe_databases::disable_maintenance', {'default_value' => false}),
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the $manage_database_maintenance parameter do from line 7? Can we move this lookup to that parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah the lookup seems like an extra step, can we just do something like maintenance_ensure = 'present' and set disable_maintenance (or change that naming also) in the pe_databases::pg_repack based on the parameter and not the lookup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure it was written this way originally. Looking at it again, I think it had something to do with disabling the vacuum class when enabling the repack class. Since we don't do that anymore, I think it makes sense to just yank out this disable_maintenance part. To me it makes sense to have this determined by pe_databases::manage_database_maintenance alone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright my previous comment is totally wrong. We need to keep the parameter at least for backwards compatibility, but also because we need a way to include the repack class and manage absent/ensure on the services and timers. So I think moving the lookup to a new parameter makes sense. I'll test that out and push a commit here if it works.

Copy link
Contributor

@MartyEwings MartyEwings left a comment

Choose a reason for hiding this comment

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

The warning message triggers when $manage_database_maintenance is set to false

message => 'This module only supports PE 2019.0.2 and later',

Copy link
Contributor

@MartyEwings MartyEwings left a comment

Choose a reason for hiding this comment

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

This all seems to work as expected, iv tested enabling and disabling backups, and the maintenance stuff.

The one thing that still is a little odd to me is this message:

notify { 'pe_databases_version_warn':
message => 'This module only supports PE 2019.0.2 and later',
loglevel => warning,

this else triggers when $manage_database_maintenance is set to false, so the message isn't quite right, as the one IF evaluates intentional disablement and version exclusion but the else only warn log message is for the versioning. This may be cumbersome but could we put an if inside the else, and only do the log warning if its the version check that gets you there?

@m0dular
Copy link
Contributor Author

m0dular commented Jun 30, 2021

That's just a small restructuring of the if/else, and it is a logic problem so we should fix it. I pushed a commit that should do it, and I also moved the databases maintenance if under the version check, since it doesn't make sense to gate some resources and not others.

Copy link
Contributor

@MartyEwings MartyEwings left a comment

Choose a reason for hiding this comment

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

Looks good to me

m0dular added 2 commits June 30, 2021 12:08
Prior to this commit, the disable_maintenance param was part of a
maintenance class that had been removed.  This commit fixes that and
moves the lookup to the param definition.
Prior to this commit, the ensure for the cron entries in the backup
class were hard coded to 'present' and could not be removed once set.
This commit adds a new parameter to manage the cron jobs based on if
$manage_database_backups is set.

Restructure if/else logic

Prior to this commit, the checks for managing the databases and having
systemd were done in the same check, so the warning was confusing.  This
commit moves $manage_database_maintenance to its own if clause.  It also
moves the $manage_database_backups inside the version check if, because
it makes more sense to put all of the resources behind the version
check.
@m0dular m0dular force-pushed the aph/disable-maintenance-fix branch from ddb2fd7 to b6ef64d Compare June 30, 2021 19:11
@MartyEwings MartyEwings merged commit d78f86b into puppetlabs:main Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pe_databases::maintenance::disable_maintenance needs reworked
3 participants