Skip to content

Fix scope of disable_maintenance param #73

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

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/pe_latest_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ jobs:
- name: Setup Acceptance Test Matrix
id: get-matrix
run: |
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\"]}"

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\"]}"
- name: "Honeycomb: Record Setup Test Matrix time"
if: ${{ always() }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pe_lts_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Setup Acceptance Test Matrix
id: get-matrix
run: |
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\"]}"
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\"]}"
- name: "Honeycomb: Record Setup Test Matrix time"
if: ${{ always() }}
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
2 changes: 0 additions & 2 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
/appveyor.yml
/.editorconfig
/.fixtures.yml
/Gemfile
/.gitattributes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can configure the retention policy by setting `pe_databases::backup::retenti
The maintenance cron jobs will perform a `VACUUM FULL` on various `pe-puppetdb` tables to keep them lean and fast.
A `VACUUM FULL` is a blocking operation and you will see the PuppetDB command queue grow while the cron jobs run.
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.
You can do so by setting `pe_databases::maintenance::disable_maintenance: true` in your hieradata.
You can do so by setting `pe_databases::disable_maintenance: true` in your hieradata.

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

Expand Down
8 changes: 7 additions & 1 deletion manifests/backup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
String $daily_databases_path = "${pe_databases::install_dir}/default_daily_databases.txt",
String $backup_logging_directory = '/var/log/puppetlabs/pe_databases_backup',
Integer $retention_policy = 2,
Boolean $disable_maintenance = true,
) {

file { $backup_logging_directory :
Expand Down Expand Up @@ -62,6 +63,11 @@
refreshonly => true,
}

$cron_ensure = $disable_maintenance ? {
false => 'present',
default => 'absent',
}

# Since the cron job titles below include the array ('databases') of database names,
# the crontab for pe-postgres needs to be reset if the array of database names changes,
# otherwise the change create a new cron job and unmanage the old cron job.
Expand All @@ -72,7 +78,7 @@
$databases_to_backup = $database_backup_set['databases']
$databases = join($databases_to_backup, ' ')
cron { "puppet_enterprise_database_backup_${databases_to_backup}":
ensure => present,
ensure => $cron_ensure,
command => "${backup_script_path} -l ${backup_logging_directory} -t ${backup_directory} -r ${retention_policy} ${databases}",
user => 'pe-postgres',
minute => $database_backup_set['schedule']['minute'],
Expand Down
32 changes: 19 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# @summary Tuning, maintenance, and backups for PE PostgreSQL.

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

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}),
if versioncmp('2019.0.2', $facts['pe_server_version']) <= 0 {
if $manage_database_maintenance {
class {'pe_databases::pg_repack':
disable_maintenance => $disable_maintenance,
}
if $manage_table_settings {
# This is to provide for situations, like PE XL,
# where the pe-puppetdb database does not exist on the PostgreSQL system being tuned.
# In PE XL, the Master and Replica run PostgreSQL for all databases *except* for pe-puppetdb.
include pe_databases::postgresql_settings::table_settings
}
}
if $manage_table_settings {
# This is to provide for situations, like PE XL,
# where the pe-puppetdb database does not exist on the PostgreSQL system being tuned.
# In PE XL, the Master and Replica run PostgreSQL for all databases *except* for pe-puppetdb.
include pe_databases::postgresql_settings::table_settings
}

if $manage_database_backups {
include pe_databases::backup
if defined('$manage_database_backups') {
class { 'pe_databases::backup':
disable_maintenance => ! $manage_database_backups,
}
}
}
else {
Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"version_requirement": ">= 5.5.0 < 8.0.0"
}
],
"pdk-version": "2.1.1",
"template-url": "https://github.com/puppetlabs/pdk-templates#2.1.1",
"template-ref": "tags/2.1.1-0-g03daa92"
"pdk-version": "2.1.0",
"template-url": "https://github.com/puppetlabs/pdk-templates#2.1.0",
"template-ref": "tags/2.1.0-0-ga675ea5"
}
12 changes: 0 additions & 12 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@
c.after(:suite) do
RSpec::Puppet::Coverage.report!(0)
end

# Filter backtrace noise
backtrace_exclusion_patterns = [
%r{spec_helper},
%r{gems},
]

if c.respond_to?(:backtrace_exclusion_patterns)
c.backtrace_exclusion_patterns = backtrace_exclusion_patterns
elsif c.respond_to?(:backtrace_clean_patterns)
c.backtrace_clean_patterns = backtrace_exclusion_patterns
end
end

# Ensures that a module is defined
Expand Down