Showing with 107 additions and 49 deletions.
  1. +4 −0 .rubocop.yml
  2. +12 −5 .sync.yml
  3. +1 −1 .travis.yml
  4. +1 −1 .vscode/extensions.json
  5. +7 −0 CHANGELOG.md
  6. +6 −7 Rakefile
  7. +35 −15 manifests/maintenance/pg_repack.pp
  8. +3 −3 metadata.json
  9. +35 −15 spec/classes/maintenance/pg_repack_spec.rb
  10. +2 −2 spec/default_facts.yml
  11. +1 −0 spec/spec_helper.rb
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/BracesAroundHashParameters:
Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0.
See https://github.com/rubocop-hq/rubocop/pull/7643
Enabled: true
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Expand Down
17 changes: 12 additions & 5 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ appveyor.yml:
.project:
delete: true
.gitlab-ci.yml:
delete: true
delete: true

spec/default_facts.yml:
extra_facts:
Expand All @@ -18,7 +18,14 @@ spec/default_facts.yml:
processors:
"count": 8

.travis.yml:
includes:
- env: PUPPET_GEM_VERSION="= 4.6.1" CHECK=parallel_spec
rvm: 2.1.9
spec/default_facts.yml:
extra_facts:
pe_postgresql_info:
installed_server_version: 9.6
pe_server_version: 2018.1.0
memory:
system:
total: 16.00 GiB
total_bytes: 17179869184
processors:
count: 8
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
stage: deploy
branches:
only:
- master
- main
- /^v\d/
notifications:
email: false
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"jpogran.puppet-vscode",
"puppet.puppet-vscode",
"rebornix.Ruby"
]
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Minor Release 1.1.0

- The reports and resource_events tables are no longer repacked when the tables are partitioned
- Update repack logging to separate files
- Update Puppet VS Code Extension ID
- Update to PDK 1.18.1

## Minor Release 1.0.1

- Correct lint issues found on the Forge
Expand Down
13 changes: 6 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,35 @@ if Bundler.rubygems.find_name('github_changelog_generator').any?
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
config.add_pr_wo_labels = true
config.issues = false
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB"
config.configure_sections = {
"Changed" => {
"prefix" => "### Changed",
"labels" => ["backwards-incompatible"],
},
"Added" => {
"prefix" => "### Added",
"labels" => ["feature", "enhancement"],
"labels" => ["enhancement", "feature"],
},
"Fixed" => {
"prefix" => "### Fixed",
"labels" => ["bugfix"],
"labels" => ["bug", "documentation", "bugfix"],
},
}
end
else
desc 'Generate a Changelog from GitHub'
task :changelog do
raise <<EOM
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
The changelog tasks depends on recent features of the github_changelog_generator gem.
Please manually add it to your .sync.yml for now, and run `pdk update`:
---
Gemfile:
optional:
':development':
- gem: 'github_changelog_generator'
git: 'https://github.com/skywinder/github-changelog-generator'
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
version: '~> 1.15'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')"
EOM
end
end
Expand Down
50 changes: 35 additions & 15 deletions manifests/maintenance/pg_repack.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@
$facts_tables = '-t factsets -t fact_paths"'
$catalogs_tables = '-t catalogs -t catalog_resources -t edges -t certnames"'
$other_tables = '-t producers -t resource_params -t resource_params_cache"'

$reports_tables = versioncmp('2019.1.0', $facts['pe_server_version']) ? {
1 => '-t reports"',
default => '-t reports -t resource_events"'
}

$logging = "> ${logging_directory}/output.log 2>&1"
$reports_table = '-t reports"'
$resource_events_table = '-t resource_events"'

Cron {
ensure => $ensure_cron,
Expand All @@ -46,27 +41,52 @@
weekday => [2,6],
hour => 4,
minute => 30,
command => "${repack} ${repack_jobs} ${facts_tables} ${logging}",
command => "${repack} ${repack_jobs} ${facts_tables} > ${logging_directory}/facts_repack.log 2>&1",
}

cron { 'pg_repack catalogs tables' :
weekday => [0,4],
hour => 4,
minute => 30,
command => "${repack} ${repack_jobs} ${catalogs_tables} ${logging}",
command => "${repack} ${repack_jobs} ${catalogs_tables} > ${logging_directory}/catalogs_repack.log 2>&1",
}

cron { 'pg_repack other tables' :
monthday => 20,
hour => 5,
minute => 30,
command => "${repack} ${repack_jobs} ${other_tables} ${logging}",
command => "${repack} ${repack_jobs} ${other_tables} > ${logging_directory}/other_repack.log 2>&1",
}

cron { 'pg_repack reports tables' :
monthday => 10,
hour => 5,
minute => 30,
command => "${repack} ${repack_jobs} ${reports_tables} ${logging}",
if versioncmp($facts['pe_server_version'], '2019.7.0') < 0 {
cron { 'pg_repack reports tables' :
monthday => 10,
hour => 5,
minute => 30,
command => "${repack} ${repack_jobs} ${reports_table} > ${logging_directory}/reports_repack.log 2>&1",
}
}
else {
cron { 'pg_repack reports tables' :
ensure => 'absent',
}
}

if versioncmp($facts['pe_server_version'], '2019.3.0') < 0 {
cron { 'pg_repack resource_events tables' :
monthday => 15,
hour => 5,
minute => 30,
command => "${repack} ${repack_jobs} ${resource_events_table} > ${logging_directory}/resource_events_repack.log 2>&1",
}
}
else {
cron { 'pg_repack resource_events tables' :
ensure => 'absent',
}
}

file { "${logging_directory}/output.log" :
ensure => absent,
}
}
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-pe_databases",
"version": "1.0.1",
"version": "1.1.0",
"author": "puppetlabs",
"summary": "A Puppet Module for Backing Up / Maintaining / Tuning Your Puppet Enterprise Databases",
"license": "Apache-2.0",
Expand Down Expand Up @@ -77,7 +77,7 @@
"version_requirement": ">= 5.5.0"
}
],
"pdk-version": "1.17.0",
"pdk-version": "1.18.1",
"template-url": "https://github.com/puppetlabs/pdk-templates#master",
"template-ref": "tags/1.17.0-0-gd3a4319"
"template-ref": "heads/master-0-gd610ead"
}
50 changes: 35 additions & 15 deletions spec/classes/maintenance/pg_repack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,68 @@
let(:facts) { os_facts }

it { is_expected.to compile }
context 'on PE 2019.1.0' do
context 'on < PE 2019.3.0' do
before :each do
facts['pe_server_version'] = '2019.1.0'
facts['pe_postgresql_info']['installed_server_version'] = 9.6
end
it {
is_expected.to contain_cron('pg_repack resource_events tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/9.6/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t resource_events" > /var/log/puppetlabs/pe_databases_cron/resource_events_repack.log 2>&1')
}
it {
is_expected.to contain_cron('pg_repack reports tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/9.6/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t reports -t resource_events" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1')
' -d pe-puppetdb --jobs 2 -t reports" > /var/log/puppetlabs/pe_databases_cron/reports_repack.log 2>&1')
}
end
context 'on > PE 2019.1.0' do
context 'on < PE 2019.3.0 with postgresql 11' do
before :each do
facts['pe_server_version'] = '2019.2.0'
facts['pe_postgresql_info']['installed_server_version'] = 9.6
facts['pe_postgresql_info']['installed_server_version'] = 11
end
it {
is_expected.to contain_cron('pg_repack resource_events tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/11/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t resource_events" > /var/log/puppetlabs/pe_databases_cron/resource_events_repack.log 2>&1')
}
it {
is_expected.to contain_cron('pg_repack reports tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/9.6/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t reports -t resource_events" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/11/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t reports" > /var/log/puppetlabs/pe_databases_cron/reports_repack.log 2>&1')
}
end
context 'on < PE 2019.1.0' do
context 'on < PE 2019.7.0' do
before :each do
facts['pe_server_version'] = '2019.0.0'
facts['pe_postgresql_info']['installed_server_version'] = 9.6
facts['pe_server_version'] = '2019.5.0'
facts['pe_postgresql_info']['installed_server_version'] = 11
end
it {
is_expected.to contain_cron('pg_repack reports tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t reports" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/11/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t reports" > /var/log/puppetlabs/pe_databases_cron/reports_repack.log 2>&1')
}
it {
is_expected.not_to contain_cron('pg_repack resource_events tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/11/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t resource_events" > /var/log/puppetlabs/pe_databases_cron/resource_events_repack.log 2>&1')
}
end
context 'on > PE 2019.1.0 with postgresql 11' do
context 'on >= PE 2019.7.0' do
before :each do
facts['pe_server_version'] = '2019.2.0'
facts['pe_server_version'] = '2019.7.0'
facts['pe_postgresql_info']['installed_server_version'] = 11
end
it {
is_expected.to contain_cron('pg_repack reports tables')
is_expected.not_to contain_cron('pg_repack reports tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/11/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t reports" > /var/log/puppetlabs/pe_databases_cron/reports_repack.log 2>&1')
}
it {
is_expected.not_to contain_cron('pg_repack resource_events tables')
.with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/11/bin/pg_repack'\
' -d pe-puppetdb --jobs 2 -t reports -t resource_events" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1')
' -d pe-puppetdb --jobs 2 -t resource_events" > /var/log/puppetlabs/pe_databases_cron/resource_events_repack.log 2>&1')
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/default_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ ipaddress: "172.16.254.254"
ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
pe_postgresql_info:
installed_server_version: 9.6
pe_server_version: 2018.1.0
memory:
system:
total: 16.00 GiB
total_bytes: 17179869184
processors:
count: 8
pe_postgresql_info:
installed_server_version: 9.6
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# set to strictest setting for testing
# by default Puppet runs at warning level
Puppet.settings[:strict] = :warning
Puppet.settings[:strict_variables] = true
end
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
c.after(:suite) do
Expand Down