Skip to content

Commit d78f86b

Browse files
authored
Merge pull request #73 from m0dular/aph/disable-maintenance-fix
Fix scope of disable_maintenance param
2 parents 25c1d4e + b6ef64d commit d78f86b

File tree

9 files changed

+32
-36
lines changed

9 files changed

+32
-36
lines changed

.github/workflows/pe_latest_testing.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ jobs:
5353
- name: Setup Acceptance Test Matrix
5454
id: get-matrix
5555
run: |
56-
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"},{\"label\":\"RedHat-8\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-8\"}],\"collection\":[\"2021.2.0\"]}"
57-
56+
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"}],\"collection\":[\"2021.1.0\"]}"
5857
- name: "Honeycomb: Record Setup Test Matrix time"
5958
if: ${{ always() }}
6059
run: |

.github/workflows/pe_lts_testing.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Setup Acceptance Test Matrix
5454
id: get-matrix
5555
run: |
56-
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-7\",\"provider\":\"provision::provision_service\",\"image\":\"centos-7\"},{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"RedHat-7\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-7\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"},{\"label\":\"RedHat-8\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-8\"}],\"collection\":[\"2019.8.7\"]}"
56+
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-7\",\"provider\":\"provision::provision_service\",\"image\":\"centos-7\"},{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"RedHat-7\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-7\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"}],\"collection\":[\"2019.8.6\"]}"
5757
- name: "Honeycomb: Record Setup Test Matrix time"
5858
if: ${{ always() }}
5959
run: |

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28-
/spec/fixtures/litmus_inventory.yaml

.pdkignore

-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28-
/spec/fixtures/litmus_inventory.yaml
2928
/appveyor.yml
30-
/.editorconfig
3129
/.fixtures.yml
3230
/Gemfile
3331
/.gitattributes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ You can configure the retention policy by setting `pe_databases::backup::retenti
6868
The maintenance cron jobs will perform a `VACUUM FULL` on various `pe-puppetdb` tables to keep them lean and fast.
6969
A `VACUUM FULL` is a blocking operation and you will see the PuppetDB command queue grow while the cron jobs run.
7070
The blocking should be short lived and the PuppetDB command queue should work itself down after, however, if for some reason you experience issues you can disable the maintenance cron jobs.
71-
You can do so by setting `pe_databases::maintenance::disable_maintenance: true` in your hieradata.
71+
You can do so by setting `pe_databases::disable_maintenance: true` in your hieradata.
7272

7373
With PE 2018.1.7 and 2019.0.2 and newer, this module uses `pg_repack` which does not block.
7474

manifests/backup.pp

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
String $daily_databases_path = "${pe_databases::install_dir}/default_daily_databases.txt",
3030
String $backup_logging_directory = '/var/log/puppetlabs/pe_databases_backup',
3131
Integer $retention_policy = 2,
32+
Boolean $disable_maintenance = true,
3233
) {
3334

3435
file { $backup_logging_directory :
@@ -62,6 +63,11 @@
6263
refreshonly => true,
6364
}
6465

66+
$cron_ensure = $disable_maintenance ? {
67+
false => 'present',
68+
default => 'absent',
69+
}
70+
6571
# Since the cron job titles below include the array ('databases') of database names,
6672
# the crontab for pe-postgres needs to be reset if the array of database names changes,
6773
# otherwise the change create a new cron job and unmanage the old cron job.
@@ -72,7 +78,7 @@
7278
$databases_to_backup = $database_backup_set['databases']
7379
$databases = join($databases_to_backup, ' ')
7480
cron { "puppet_enterprise_database_backup_${databases_to_backup}":
75-
ensure => present,
81+
ensure => $cron_ensure,
7682
command => "${backup_script_path} -l ${backup_logging_directory} -t ${backup_directory} -r ${retention_policy} ${databases}",
7783
user => 'pe-postgres',
7884
minute => $database_backup_set['schedule']['minute'],

manifests/init.pp

+19-13
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
# @summary Tuning, maintenance, and backups for PE PostgreSQL.
44

55
class pe_databases (
6-
Boolean $manage_database_backups = false,
6+
Variant[Boolean,Undef] $manage_database_backups = undef,
7+
# Manage the inclusion of the pg_repack class
78
Boolean $manage_database_maintenance = true,
9+
# Manage the state of the maintenance tasks, i.e. systemd services and timers
10+
Boolean $disable_maintenance = lookup('pe_databases::disable_maintenance', {'default_value' => false}),
811
Boolean $manage_postgresql_settings = true,
912
Boolean $manage_table_settings = true,
1013
String $install_dir = '/opt/puppetlabs/pe_databases',
@@ -28,19 +31,22 @@
2831
}
2932

3033
if $facts.dig('pe_databases', 'have_systemd') {
31-
if $manage_database_maintenance and (versioncmp('2019.0.2', $facts['pe_server_version']) <= 0) {
32-
class {'pe_databases::pg_repack':
33-
disable_maintenance => lookup('pe_databases::maintenance::disable_maintenance', {'default_value' => false}),
34+
if versioncmp('2019.0.2', $facts['pe_server_version']) <= 0 {
35+
if $manage_database_maintenance {
36+
class {'pe_databases::pg_repack':
37+
disable_maintenance => $disable_maintenance,
38+
}
39+
if $manage_table_settings {
40+
# This is to provide for situations, like PE XL,
41+
# where the pe-puppetdb database does not exist on the PostgreSQL system being tuned.
42+
# In PE XL, the Master and Replica run PostgreSQL for all databases *except* for pe-puppetdb.
43+
include pe_databases::postgresql_settings::table_settings
44+
}
3445
}
35-
if $manage_table_settings {
36-
# This is to provide for situations, like PE XL,
37-
# where the pe-puppetdb database does not exist on the PostgreSQL system being tuned.
38-
# In PE XL, the Master and Replica run PostgreSQL for all databases *except* for pe-puppetdb.
39-
include pe_databases::postgresql_settings::table_settings
40-
}
41-
42-
if $manage_database_backups {
43-
include pe_databases::backup
46+
if defined('$manage_database_backups') {
47+
class { 'pe_databases::backup':
48+
disable_maintenance => ! $manage_database_backups,
49+
}
4450
}
4551
}
4652
else {

metadata.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"version_requirement": ">= 5.5.0 < 8.0.0"
5454
}
5555
],
56-
"pdk-version": "2.1.1",
57-
"template-url": "https://github.com/puppetlabs/pdk-templates#2.1.1",
58-
"template-ref": "tags/2.1.1-0-g03daa92"
56+
"pdk-version": "2.1.0",
57+
"template-url": "https://github.com/puppetlabs/pdk-templates#2.1.0",
58+
"template-ref": "tags/2.1.0-0-ga675ea5"
5959
}

spec/spec_helper.rb

-12
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@
4848
c.after(:suite) do
4949
RSpec::Puppet::Coverage.report!(0)
5050
end
51-
52-
# Filter backtrace noise
53-
backtrace_exclusion_patterns = [
54-
%r{spec_helper},
55-
%r{gems},
56-
]
57-
58-
if c.respond_to?(:backtrace_exclusion_patterns)
59-
c.backtrace_exclusion_patterns = backtrace_exclusion_patterns
60-
elsif c.respond_to?(:backtrace_clean_patterns)
61-
c.backtrace_clean_patterns = backtrace_exclusion_patterns
62-
end
6351
end
6452

6553
# Ensures that a module is defined

0 commit comments

Comments
 (0)