-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PE-39352) Update backup/restore plans for hac database
PE 2023.7.0 added the host-action-collector service and the backup/restore plans need to be made aware of the pe-hac database. This patch adds a version test, best on the addition of pe_version check of /opt/puppetlabs/server/pe_build in the peadm::get_peadm_config task. If >= 2023.7, then pe-hac is added to the defaults returned by the various recover_opts functions that define which resource backup/restore should wrangle. The patch does not attempt to version test the user's custom override hash of selections, on the assumption that they know, or should be allowed to specify whatever is needed. If pe_version is not found (damaged cluster, missing from peadm_config.json), the patch defaults to assuming earliest version, which will skip pe-hac. This favors the plans running without error at the cost of possibly missing pe-hac in a newer installation. Alternately, we could reverse this and incur failures in damaged older clusters requiring use of $custom to work around. Finally there is an edge case it does not address which is the case of newer pe versions with pe-hac restoring tarballs that were intended to include all databases, but which were created with peadm predating this patch. These will fail the pg-restore pe-hac commands, since pe-hac won't be in the backup, and again require use of $custom to work around.
- Loading branch information
Showing
16 changed files
with
372 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function peadm::amend_recovery_defaults_by_pe_version ( | ||
Hash $base_opts, | ||
Peadm::Pe_version $pe_version, | ||
Boolean $opt_value, | ||
) { | ||
# work around puppet-lint check_unquoted_string_in_case | ||
$semverrange = SemVerRange('>= 2023.7') | ||
case $pe_version { | ||
$semverrange: { | ||
$base_opts + { | ||
'hac' => $opt_value, | ||
} | ||
} | ||
default: { | ||
$base_opts | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Verify that *pe_version* string is a valid SemVer. | ||
# If not, warn, and return "0.0.0" as a permissive default. | ||
function peadm::validated_pe_version_for_backup_restore( | ||
Optional[String] $pe_version, | ||
) { | ||
# work around puppet-lint check_unquoted_string_in_case | ||
$semverrange = SemVerRange('>=0.0.0') | ||
case $pe_version { | ||
# Validate that the value is a SemVer value. | ||
$semverrange: { | ||
$pe_version | ||
} | ||
default: { | ||
$msg = @("WARN") | ||
WARNING: Retrieved a missing or unparseable PE version of '${pe_version}'. | ||
The host_action_collector database will be skipped from defaults. | ||
|-WARN | ||
out::message($msg) | ||
'0.0.0' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"pe_version" : "2023.7.0", | ||
"params": { "primary_host": "primary", "primary_postgresql_host": "postgres" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"params": { "primary_host": "primary", "primary_postgresql_host": "postgres" } | ||
} |
15 changes: 15 additions & 0 deletions
15
spec/functions/amend_recovery_defaults_by_pe_version_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe 'peadm::amend_recovery_defaults_by_pe_version' do | ||
it 'just returns the base opts if version < 2023.7' do | ||
is_expected.to run.with_params({}, '2023.6.0', true).and_return({}) | ||
end | ||
|
||
it 'adds hac if version >= 2023.7' do | ||
is_expected.to run.with_params({}, '2023.7.0', true).and_return({ 'hac' => true }) | ||
end | ||
|
||
it 'adds hac false based on opt_value' do | ||
is_expected.to run.with_params({}, '2023.7.0', false).and_return({ 'hac' => false }) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe 'peadm::migration_opts_default' do | ||
it 'returns pre 2023.7 defaults' do | ||
is_expected.to run.with_params('2023.6.0').and_return( | ||
{ | ||
'activity' => true, | ||
'ca' => true, | ||
'classifier' => true, | ||
'code' => false, | ||
'config' => false, | ||
'orchestrator' => true, | ||
'puppetdb' => true, | ||
'rbac' => true, | ||
}, | ||
) | ||
end | ||
|
||
it 'returns 2023.7+ defaults with hac' do | ||
is_expected.to run.with_params('2023.7.0').and_return( | ||
{ | ||
'activity' => true, | ||
'ca' => true, | ||
'classifier' => true, | ||
'code' => false, | ||
'config' => false, | ||
'orchestrator' => true, | ||
'puppetdb' => true, | ||
'rbac' => true, | ||
'hac' => true, | ||
}, | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe 'peadm::recovery_opts_all' do | ||
it 'returns pre 2023.7 defaults' do | ||
is_expected.to run.with_params('2023.6.0').and_return( | ||
{ | ||
'activity' => true, | ||
'ca' => true, | ||
'classifier' => true, | ||
'code' => true, | ||
'config' => true, | ||
'orchestrator' => true, | ||
'puppetdb' => true, | ||
'rbac' => true, | ||
}, | ||
) | ||
end | ||
|
||
it 'returns 2023.7+ defaults with hac' do | ||
is_expected.to run.with_params('2023.7.0').and_return( | ||
{ | ||
'activity' => true, | ||
'ca' => true, | ||
'classifier' => true, | ||
'code' => true, | ||
'config' => true, | ||
'orchestrator' => true, | ||
'puppetdb' => true, | ||
'rbac' => true, | ||
'hac' => true, | ||
}, | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe 'peadm::recovery_opts_default' do | ||
it 'returns pre 2023.7 defaults' do | ||
is_expected.to run.with_params('2023.6.0').and_return( | ||
{ | ||
'activity' => false, | ||
'ca' => true, | ||
'classifier' => false, | ||
'code' => true, | ||
'config' => true, | ||
'orchestrator' => false, | ||
'puppetdb' => true, | ||
'rbac' => false, | ||
}, | ||
) | ||
end | ||
|
||
it 'returns 2023.7+ defaults with hac' do | ||
is_expected.to run.with_params('2023.7.0').and_return( | ||
{ | ||
'activity' => false, | ||
'ca' => true, | ||
'classifier' => false, | ||
'code' => true, | ||
'config' => true, | ||
'orchestrator' => false, | ||
'puppetdb' => true, | ||
'rbac' => false, | ||
'hac' => false, | ||
}, | ||
) | ||
end | ||
end |
Oops, something went wrong.