Skip to content

Commit 5d11e72

Browse files
committed
(SUP-3672) Remove legacy code and add spec tests
1 parent a049a45 commit 5d11e72

10 files changed

+126
-379
lines changed

functions/version_based_databases.pp

-22
This file was deleted.

manifests/init.pp

+3-26
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,12 @@
1818
class pe_databases (
1919
Boolean $manage_database_maintenance = true,
2020
Boolean $disable_maintenance = false,
21-
Boolean $manage_postgresql_settings = true,
22-
Boolean $manage_table_settings = false,
2321
String[1] $install_dir = '/opt/puppetlabs/pe_databases',
2422
String[1] $scripts_dir = "${install_dir}/scripts",
2523
String[1] $facts_tables_repack_timer = 'Tue,Sat *-*-* 04:30:00',
2624
String[1] $catalogs_tables_repack_timer = 'Sun,Thu *-*-* 04:30:00',
2725
String[1] $other_tables_repack_timer = '*-*-20 05:30:00',
28-
String[1] $reports_tables_repack_timer = '*-*-10 05:30:00',
29-
String[1] $resource_events_tables_repack_timer = '*-*-15 05:30:00',
3026
) {
31-
$psql_version = $facts['pe_postgresql_info']['installed_server_version'] ? {
32-
undef => undef,
33-
default => String($facts['pe_postgresql_info']['installed_server_version'])
34-
}
35-
3627
file { [$install_dir, $scripts_dir]:
3728
ensure => directory,
3829
mode => '0755',
@@ -45,23 +36,9 @@
4536
}
4637

4738
if $facts.dig('pe_databases', 'have_systemd') {
48-
if versioncmp('2019.0.2', $facts['pe_server_version']) <= 0 {
49-
if $manage_database_maintenance {
50-
class { 'pe_databases::pg_repack':
51-
disable_maintenance => $disable_maintenance,
52-
}
53-
if $manage_table_settings {
54-
# This is to provide for situations, like PE XL,
55-
# where the pe-puppetdb database does not exist on the PostgreSQL system being tuned.
56-
# In PE XL, the Primary and Replica run PostgreSQL for all databases *except* for pe-puppetdb.
57-
include pe_databases::postgresql_settings::table_settings
58-
}
59-
}
60-
}
61-
else {
62-
notify { 'pe_databases_version_warn':
63-
message => 'This module only supports PE 2019.0.2 and later',
64-
loglevel => warning,
39+
if $manage_database_maintenance {
40+
class { 'pe_databases::pg_repack':
41+
disable_maintenance => $disable_maintenance,
6542
}
6643
}
6744
}

manifests/pg_repack.pp

+8-39
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,40 @@
99
# @param facts_tables_repack_timer [String] The Systemd timer for the pg_repack job affecting the 'facts' tables
1010
# @param catalogs_tables_repack_timer [String]The Systemd timer for the pg_repack job affecting the 'catalog' tables
1111
# @param other_tables_repack_timer [String] The Systemd timer for the pg_repack job affecting the 'other' tables
12-
# @param reports_tables_repack_timer [String] The Systemd timer for the pg_repack job affecting the 'reports' tables
13-
# @param resource_events_tables_repack_timer [String] The Systemd timer for the pg_repack job affecting the 'resource_events' tables
1412
class pe_databases::pg_repack (
1513
Boolean $disable_maintenance = false,
1614
Integer $jobs = $facts['processors']['count'] / 4,
1715
String[1] $facts_tables_repack_timer = $pe_databases::facts_tables_repack_timer,
1816
String[1] $catalogs_tables_repack_timer = $pe_databases::catalogs_tables_repack_timer,
1917
String[1] $other_tables_repack_timer = $pe_databases::other_tables_repack_timer,
20-
String[1] $reports_tables_repack_timer = $pe_databases::reports_tables_repack_timer,
21-
String[1] $resource_events_tables_repack_timer = $pe_databases::resource_events_tables_repack_timer,
2218
) {
23-
# PE 2019.1 starting shipping versioned pe-postgres packages where all paths are versioned.
24-
# So, prior to 2019.1 use a non-versioned path, and after use a versioned path.
25-
# TODO: Use $pe_databases::psql_version after identifying why it is cast to ${psql_version}00000 in spec tests.
2619
$postgresql_version = $facts['pe_postgresql_info']['installed_server_version']
27-
$repack_executable = versioncmp('2019.1.0', $facts['pe_server_version']) ? {
28-
1 => '/opt/puppetlabs/server/apps/postgresql/bin/pg_repack',
29-
default => "/opt/puppetlabs/server/apps/postgresql/${postgresql_version}/bin/pg_repack"
30-
}
20+
$repack_executable = "/opt/puppetlabs/server/apps/postgresql/${postgresql_version}/bin/pg_repack"
3121

32-
$repack = "${repack_executable} -d pe-puppetdb"
33-
$repack_jobs = "--jobs ${jobs}"
22+
$repack_cmd = "${repack_executable} -d pe-puppetdb --jobs ${jobs}"
3423

35-
$facts_tables = '-t factsets -t fact_paths'
36-
$catalogs_tables = versioncmp($facts['pe_server_version'], '2019.8.1') ? {
37-
1 => '-t catalogs -t catalog_resources -t catalog_inputs -t edges -t certnames',
38-
default => '-t catalogs -t catalog_resources -t edges -t certnames' }
39-
$other_tables = '-t producers -t resource_params -t resource_params_cache'
40-
$reports_table = '-t reports'
41-
$resource_events_table = '-t resource_events'
24+
$fact_tables = '-t factsets -t fact_paths'
25+
$catalog_tables = '-t catalogs -t catalog_resources -t catalog_inputs -t edges -t certnames'
26+
$other_tables = '-t producers -t resource_params -t resource_params_cache'
4227

4328
pe_databases::collect { 'facts':
4429
disable_maintenance => $disable_maintenance,
45-
command => "${repack} ${repack_jobs} ${facts_tables}",
30+
command => "${repack_cmd} ${fact_tables}",
4631
on_cal => $facts_tables_repack_timer,
4732
}
4833

4934
pe_databases::collect { 'catalogs':
5035
disable_maintenance => $disable_maintenance,
51-
command => "${repack} ${repack_jobs} ${catalogs_tables}",
36+
command => "${repack_cmd} ${catalog_tables}",
5237
on_cal => $catalogs_tables_repack_timer,
5338
}
5439

5540
pe_databases::collect { 'other':
5641
disable_maintenance => $disable_maintenance,
57-
command => "${repack} ${repack_jobs} ${other_tables}",
42+
command => "${repack_cmd} ${other_tables}",
5843
on_cal => $other_tables_repack_timer,
5944
}
6045

61-
if versioncmp($facts['pe_server_version'], '2019.7.0') < 0 {
62-
pe_databases::collect { 'reports':
63-
disable_maintenance => $disable_maintenance,
64-
command => "${repack} ${repack_jobs} ${reports_table}",
65-
on_cal => $reports_tables_repack_timer,
66-
}
67-
}
68-
69-
if versioncmp($facts['pe_server_version'], '2019.3.0') < 0 {
70-
pe_databases::collect { 'resource_events':
71-
disable_maintenance => $disable_maintenance,
72-
command => "${repack} ${repack_jobs} ${resource_events_table}",
73-
on_cal => $resource_events_tables_repack_timer,
74-
}
75-
}
76-
7746
# Ensure legacy vaccum and pg_repack crons are purged.
7847
# If someone upgrades from an ancient v0.x version of the pe_databases module to 2.0 or newer,
7948
# the old cron jobs running vaccuum full will not be cleaned up. This can result in a deadlock

manifests/postgresql_settings.pp

-126
This file was deleted.

manifests/postgresql_settings/table_settings.pp

-54
This file was deleted.

manifests/set_puppetdb_table_autovacuum_cost_delay_zero.pp

-17
This file was deleted.

manifests/set_table_attribute.pp

-31
This file was deleted.

0 commit comments

Comments
 (0)