Skip to content

Commit cdb7fe9

Browse files
(#469) Upgrade: Assign production environment to node groups
This makes the environment for node groups configureable. The default is 'production'. This is also the default in the node_group resource type: https://github.com/puppetlabs/puppetlabs-node_manager/blob/main/lib/puppet/type/node_group.rb#L124 We could also default to `undef` in PEADM and rely on the node_manage module, but explicitly setting `production` seems to be safer. This is related to #469 and makes the environment configureable during upgrades. Co-authored-by: David Mallon <[email protected]>
1 parent e243c14 commit cdb7fe9

File tree

9 files changed

+71
-7
lines changed

9 files changed

+71
-7
lines changed

REFERENCE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,12 +1832,21 @@ The peadm::add_database class.
18321832

18331833
The following parameters are available in the `peadm::add_database` plan:
18341834

1835+
* [`node_group_environment`](#-peadm--add_database--node_group_environment)
18351836
* [`targets`](#-peadm--add_database--targets)
18361837
* [`primary_host`](#-peadm--add_database--primary_host)
18371838
* [`mode`](#-peadm--add_database--mode)
18381839
* [`begin_at_step`](#-peadm--add_database--begin_at_step)
18391840
* [`is_migration`](#-peadm--add_database--is_migration)
18401841

1842+
##### <a name="-peadm--add_database--node_group_environment"></a>`node_group_environment`
1843+
1844+
Data type: `String[1]`
1845+
1846+
environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
1847+
1848+
Default value: `'production'`
1849+
18411850
##### <a name="-peadm--add_database--targets"></a>`targets`
18421851

18431852
Data type: `Peadm::SingleTargetSpec`
@@ -1899,6 +1908,7 @@ The following parameters are available in the `peadm::add_replica` plan:
18991908
* [`replica_host`](#-peadm--add_replica--replica_host)
19001909
* [`replica_postgresql_host`](#-peadm--add_replica--replica_postgresql_host)
19011910
* [`token_file`](#-peadm--add_replica--token_file)
1911+
* [`node_group_environment`](#-peadm--add_replica--node_group_environment)
19021912

19031913
##### <a name="-peadm--add_replica--primary_host"></a>`primary_host`
19041914

@@ -1929,6 +1939,14 @@ Data type: `Optional[String]`
19291939

19301940
Default value: `undef`
19311941

1942+
##### <a name="-peadm--add_replica--node_group_environment"></a>`node_group_environment`
1943+
1944+
Data type: `String[1]`
1945+
1946+
environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
1947+
1948+
Default value: `'production'`
1949+
19321950
### <a name="peadm--backup"></a>`peadm::backup`
19331951

19341952
Backup puppet primary configuration
@@ -2016,6 +2034,7 @@ management using PEAdm.
20162034
The following parameters are available in the `peadm::convert` plan:
20172035

20182036
* [`begin_at_step`](#-peadm--convert--begin_at_step)
2037+
* [`node_group_environment`](#-peadm--convert--node_group_environment)
20192038
* [`primary_host`](#-peadm--convert--primary_host)
20202039
* [`replica_host`](#-peadm--convert--replica_host)
20212040
* [`compiler_hosts`](#-peadm--convert--compiler_hosts)
@@ -2035,6 +2054,14 @@ The step where the plan should start. If not set, it will start at the beginning
20352054

20362055
Default value: `undef`
20372056

2057+
##### <a name="-peadm--convert--node_group_environment"></a>`node_group_environment`
2058+
2059+
Data type: `String[1]`
2060+
2061+
environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
2062+
2063+
Default value: `peadm::get_node_group_environment($primary_host)`
2064+
20382065
##### <a name="-peadm--convert--primary_host"></a>`primary_host`
20392066

20402067
Data type: `Peadm::SingleTargetSpec`
@@ -2723,6 +2750,7 @@ The following parameters are available in the `peadm::upgrade` plan:
27232750
* [`stagingdir`](#-peadm--upgrade--stagingdir)
27242751
* [`uploaddir`](#-peadm--upgrade--uploaddir)
27252752
* [`begin_at_step`](#-peadm--upgrade--begin_at_step)
2753+
* [`node_group_environment`](#-peadm--upgrade--node_group_environment)
27262754
* [`primary_host`](#-peadm--upgrade--primary_host)
27272755
* [`replica_host`](#-peadm--upgrade--replica_host)
27282756
* [`compiler_hosts`](#-peadm--upgrade--compiler_hosts)
@@ -2819,6 +2847,14 @@ The step where the plan should start. If not set, it will start at the beginning
28192847

28202848
Default value: `undef`
28212849

2850+
##### <a name="-peadm--upgrade--node_group_environment"></a>`node_group_environment`
2851+
2852+
Data type: `String[1]`
2853+
2854+
environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
2855+
2856+
Default value: `'production'`
2857+
28222858
##### <a name="-peadm--upgrade--primary_host"></a>`primary_host`
28232859

28242860
Data type: `Peadm::SingleTargetSpec`

manifests/setup/legacy_compiler_group.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
String[1] $primary_host,
44
Optional[String] $internal_compiler_a_pool_address = undef,
55
Optional[String] $internal_compiler_b_pool_address = undef,
6+
String[1] $node_group_environment = 'production',
67
) {
78
Node_group {
89
purge_behavior => none,
10+
environment => $node_group_environment,
911
}
1012

1113
node_group { 'PE Legacy Compiler':

manifests/setup/node_manager.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# A load balancer address directing traffic to any of the "B" pool
2424
# compilers. This is used for DR configuration in large and extra large
2525
# architectures.
26+
# @param node_group_environment the environment that will be assigned to all the PE Infra node groups
2627
#
2728
class peadm::setup::node_manager (
2829
String[1] $primary_host,
@@ -36,6 +37,7 @@
3637
Optional[String[1]] $compiler_pool_address = undef,
3738
Optional[String[1]] $internal_compiler_a_pool_address = $server_a_host,
3839
Optional[String[1]] $internal_compiler_b_pool_address = $server_b_host,
40+
String[1] $node_group_environment = 'production',
3941
) {
4042
# "Not-configured" placeholder string. This will be used in places where we
4143
# cannot set an explicit null, and need to supply some kind of value.
@@ -46,6 +48,7 @@
4648
# else.
4749
Node_group {
4850
purge_behavior => none,
51+
environment => $node_group_environment,
4952
}
5053

5154
##################################################

plans/add_database.pp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#
2+
# @param node_group_environment environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
3+
#
14
plan peadm::add_database(
25
Peadm::SingleTargetSpec $targets,
36
Peadm::SingleTargetSpec $primary_host,
@@ -10,6 +13,7 @@
1013
'cleanup-db',
1114
'finalize']] $begin_at_step = undef,
1215
Optional[Boolean] $is_migration = false,
16+
String[1] $node_group_environment = 'production',
1317
) {
1418
$primary_target = peadm::get_targets($primary_host, 1)
1519
$postgresql_target = peadm::get_targets($targets, 1)
@@ -135,15 +139,17 @@
135139
$host = pick($a_host, $b_host)
136140
out::verbose("In transitive state, setting classification to ${host}")
137141
run_plan('peadm::util::update_classification', $primary_target,
138-
postgresql_a_host => $host,
139-
postgresql_b_host => $host,
140-
peadm_config => $peadm_config
142+
postgresql_a_host => $host,
143+
postgresql_b_host => $host,
144+
peadm_config => $peadm_config,
145+
node_group_environment => $node_group_environment,
141146
)
142147
} else {
143148
run_plan('peadm::util::update_classification', $primary_target,
144-
postgresql_a_host => $avail_group_letter ? { 'A' => $postgresql_host, default => undef },
145-
postgresql_b_host => $avail_group_letter ? { 'B' => $postgresql_host, default => undef },
146-
peadm_config => $peadm_config
149+
postgresql_a_host => $avail_group_letter ? { 'A' => $postgresql_host, default => undef },
150+
postgresql_b_host => $avail_group_letter ? { 'B' => $postgresql_host, default => undef },
151+
peadm_config => $peadm_config,
152+
node_group_environment => $node_group_environment,
147153
)
148154
}
149155
}

plans/add_replica.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# @param replica_postgresql_host - The hostname and certname of the host with the replica PE-PosgreSQL database.
88
# Can be a separate host in an XL architecture, or undef in Standard or Large.
99
# @param token_file - (optional) the token file in a different location than the default.
10+
# @param node_group_environment environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
1011
plan peadm::add_replica(
1112
# Standard or Large
1213
Peadm::SingleTargetSpec $primary_host,
@@ -17,6 +18,7 @@
1718

1819
# Common Configuration
1920
Optional[String] $token_file = undef,
21+
String[1] $node_group_environment = 'production',
2022
) {
2123
$primary_target = peadm::get_targets($primary_host, 1)
2224
$replica_target = peadm::get_targets($replica_host, 1)
@@ -96,7 +98,8 @@
9698
server_b_host => $replica_avail_group_letter ? { 'B' => $replica_target.peadm::certname(), default => undef },
9799
internal_compiler_a_pool_address => $replica_avail_group_letter ? { 'A' => $replica_target.peadm::certname(), default => undef },
98100
internal_compiler_b_pool_address => $replica_avail_group_letter ? { 'B' => $replica_target.peadm::certname(), default => undef },
99-
peadm_config => $peadm_config
101+
peadm_config => $peadm_config,
102+
node_group_environment => $node_group_environment,
100103
)
101104

102105
# Source list of files on Primary and synchronize to new Replica

plans/convert.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# management using PEAdm.
66
#
77
# @param begin_at_step The step where the plan should start. If not set, it will start at the beginning
8+
# @param node_group_environment environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
89
#
910
plan peadm::convert (
1011
# Standard
@@ -26,6 +27,7 @@
2627
Array[String] $dns_alt_names = [],
2728

2829
Optional[Peadm::ConvertSteps] $begin_at_step = undef,
30+
String[1] $node_group_environment = peadm::get_node_group_environment($primary_host),
2931
) {
3032
peadm::assert_supported_bolt_version()
3133

@@ -316,6 +318,7 @@
316318
compiler_pool_address => $compiler_pool_address,
317319
internal_compiler_a_pool_address => $internal_compiler_a_pool_address,
318320
internal_compiler_b_pool_address => $internal_compiler_b_pool_address,
321+
node_group_environment => $node_group_environment,
319322
require => Class['peadm::setup::node_manager_yaml'],
320323
}
321324

plans/convert_compiler_to_legacy.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Peadm::SingleTargetSpec $primary_host,
44
TargetSpec $legacy_hosts,
55
Optional[Boolean] $remove_pdb = true,
6+
String[1] $node_group_environment = 'production',
67
) {
78
$primary_target = peadm::get_targets($primary_host, 1)
89
$convert_legacy_compiler_targets = peadm::get_targets($legacy_hosts)
@@ -34,6 +35,7 @@
3435
},
3536
internal_compiler_a_pool_address => getvar('cluster.params.internal_compiler_a_pool_address'),
3637
internal_compiler_b_pool_address => getvar('cluster.params.internal_compiler_b_pool_address'),
38+
node_group_environment => $node_group_environment,
3739
require => Class['peadm::setup::node_manager_yaml'],
3840
}
3941
}

plans/upgrade.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
# for offline usage.
3333
# @param begin_at_step The step where the plan should start. If not set, it will start at the beginning
3434
#
35+
# @param node_group_environment environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
36+
#
3537
plan peadm::upgrade (
3638
# Standard
3739
Peadm::SingleTargetSpec $primary_host,
@@ -61,6 +63,7 @@
6163
Boolean $permit_unsafe_versions = false,
6264

6365
Optional[Peadm::UpgradeSteps] $begin_at_step = undef,
66+
String[1] $node_group_environment = 'production',
6467
) {
6568
# Log parameters for debugging
6669
peadm::log_plan_parameters({
@@ -69,6 +72,7 @@
6972
'compiler_hosts' => $compiler_hosts,
7073
'primary_postgresql_host' => $primary_postgresql_host,
7174
'replica_postgresql_host' => $replica_postgresql_host,
75+
'node_group_environment' => $node_group_environment,
7276
'version' => $version,
7377
})
7478

@@ -361,6 +365,7 @@
361365
compiler_pool_address => $compiler_pool_address,
362366
internal_compiler_a_pool_address => $internal_compiler_a_pool_address,
363367
internal_compiler_b_pool_address => $internal_compiler_b_pool_address,
368+
node_group_environment => $node_group_environment,
364369
require => Class['peadm::setup::node_manager_yaml'],
365370
}
366371
}

plans/util/update_classification.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
#
33
# @summary Configure classification
44
#
5+
# @param node_group_environment environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
6+
#
57
plan peadm::util::update_classification (
68
# Standard
79
Peadm::SingleTargetSpec $targets,
10+
String[1] $node_group_environment,
811
Optional[Hash] $peadm_config = undef,
912
Optional[Peadm::SingleTargetSpec] $server_a_host = undef,
1013
Optional[Peadm::SingleTargetSpec] $server_b_host = undef,
@@ -76,6 +79,7 @@
7679
compiler_pool_address => $new['params']['compiler_pool_address'],
7780
internal_compiler_a_pool_address => $new['params']['internal_compiler_a_pool_address'],
7881
internal_compiler_b_pool_address => $new['params']['internal_compiler_b_pool_address'],
82+
node_group_environment => $node_group_environment,
7983
require => Class['peadm::setup::node_manager_yaml'],
8084
}
8185
}

0 commit comments

Comments
 (0)