Skip to content

Commit

Permalink
(SUP-4666) Implementation of conditional logic for enabling debug, ec…
Browse files Browse the repository at this point in the history
…ho WITH acceptance test modifications
  • Loading branch information
Aaronoftheages committed Jan 30, 2024
1 parent 7d95c01 commit 1f8389f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion manifests/pg_repack.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# @param activity_tables [Array] Array of 'activity' tables to repack
# @param disable_maintenance [Boolean] true or false (Default: false)
# Disable or enable maintenance mode
# @param repack_log_level [Enum] Desired output level of logs
# @param enable_echo [Boolean] true or false (Default: true)
# Enabling echo output in logs
# @param jobs [Integer] How many jobs to run in parallel
# @param facts_tables_repack_timer [String] The Systemd timer for the pg_repack job affecting the 'facts' tables
# @param catalogs_tables_repack_timer [String]The Systemd timer for the pg_repack job affecting the 'catalog' tables
Expand All @@ -22,6 +25,8 @@
Array $other_tables,
Array $activity_tables,
Boolean $disable_maintenance = false,
Enum['INFO','NOTICE','WARNING','ERROR','LOG','FATAL','PANIC','DEBUG'] $repack_log_level='DEBUG',
Boolean $enable_echo = true,
Integer $jobs = $facts['processors']['count'] / 4,
String[1] $facts_tables_repack_timer = $pe_databases::facts_tables_repack_timer,
String[1] $catalogs_tables_repack_timer = $pe_databases::catalogs_tables_repack_timer,
Expand All @@ -36,7 +41,11 @@
$postgresql_version = $facts['pe_postgresql_info']['installed_server_version']
$repack_executable = "/opt/puppetlabs/server/apps/postgresql/${postgresql_version}/bin/pg_repack"

$repack_cmd = "${repack_executable} --jobs ${jobs}"
if $enable_echo {
$repack_cmd = "${repack_executable} --jobs ${jobs} --elevel ${repack_log_level} --echo"
} else {
$repack_cmd = "${repack_executable} --jobs ${jobs} --elevel ${repack_log_level}"
}

pe_databases::collect { 'facts':
disable_maintenance => $disable_maintenance,
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/pg_repack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
tables_hash.each do |name, val|
is_expected.to contain_pe_databases__collect(name).with(
disable_maintenance: false,
command: "#{repack_cmd} #{val[:database]}",
command: "#{repack_cmd} --elevel DEBUG --echo #{val[:database]}",
# Strip the backslash character because this is not a regex
on_cal: (val[:schedule]).to_s.tr('\\', ''),
)
Expand All @@ -66,7 +66,7 @@

is_expected.to contain_file("/etc/systemd/system/pe_databases-#{name}.timer").with_content(%r{OnCalendar=#{val[:schedule]}})
is_expected.to contain_file("/etc/systemd/system/pe_databases-#{name}.service").with_content(
%r{ExecStart=#{repack_cmd} #{val[:database]} #{val[:tables]}},
%r{ExecStart=#{repack_cmd} --elevel DEBUG --echo #{val[:database]} #{val[:tables]}},
)

[
Expand Down

0 comments on commit 1f8389f

Please sign in to comment.