Implement stonith levels and enable kdump agent.
This commit extends the stonith generation logic to allow operators
to make use of fencing levels.
Given a fence.yaml file like the following:
parameter_defaults:
EnableFencing: true
FencingConfig:
devices:
level1:
- agent: fence_agent1
host_mac: aa:bb:cc:dd:ee:ff
params:
someparam: somevalue
level2:
- agent: fence_agent2
host_mac: aa:bb:cc:dd:ee:ff
params:
someotherparam: someothervalue
The code iterates over the "levelX" key and creates the respective
stonith resources and adds them to the specified stonith level.
It should be backwards compatible since it checks if "devices" is
an array (no level specified) and reconducts this case to level=1.
Example results below.
* without levels:*
hieradata:
"tripleo::fencing::config": {
"devices": [
{
"agent": "fence_ipmilan",
"host_mac": "e4:43:4b:4b:c8:19",
[root@overcloud-controller-0]# pcs status
...
stonith-fence_ipmilan-e4434b4bc819 (stonith:fence_ipmilan): Started overcloud-controller-1
[root@overcloud-controller-0]# pcs stonith level
Target: overcloud-controller-0
Level 1 - stonith-fence_ipmilan-e4434b4bc819
* with levels: *
hieradata:
"tripleo::fencing::config": {
"devices": {
"level1": [
{
"agent": "fence_ipmilan",
"host_mac": "e4:43:4b:4b:c8:19",
...
"level2": [
{
"agent": "fence_kdump",
"host_mac": "e4:43:4b:4b:c8:19",
[root@overcloud-controller-0 ]# pcs status
...
stonith-fence_ipmilan-e4434b4bc819 (stonith:fence_ipmilan): Started overcloud-controller-1
stonith-fence_kdump-e4434b4bc819 (stonith:fence_kdump): Started overcloud-controller-2
[root@overcloud-controller-0 ]# pcs stonith level
Target: overcloud-controller-0
Level 1 - stonith-fence_ipmilan-e4434b4bc819
Level 2 - stonith-fence_kdump-e4434b4bc819
Change-Id: I42033be840ba41e9944af65815a63059834144e9
(cherry picked from commit bacfec8647
)
This commit is contained in:
parent
993e19ed5d
commit
67eb9743f3
|
@ -57,51 +57,77 @@ class tripleo::fencing(
|
|||
'tries' => $tries,
|
||||
'try_sleep' => $try_sleep,
|
||||
}
|
||||
# We will create stonith levels *only* if the node is a compute instanceha one
|
||||
|
||||
# check if instanceha is enabled
|
||||
if member(hiera('compute_instanceha_short_node_names', []), downcase($::hostname)) {
|
||||
$is_compute_instanceha_node = true
|
||||
} else {
|
||||
$is_compute_instanceha_node = false
|
||||
}
|
||||
|
||||
$content = $config['devices']
|
||||
|
||||
$all_devices = $config['devices']
|
||||
|
||||
if $::uuid != 'docker' and $::deployment_type != 'containers' {
|
||||
$xvm_devices = local_fence_devices('fence_xvm', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_xvm', $xvm_devices, $common_params)
|
||||
# check if the devices: section in fence.yaml contains levels.
|
||||
# if it doesn't, assume level=1 an build a hash with the content.
|
||||
if is_array($content) {
|
||||
$all_levels = {'level1' => $content}
|
||||
}
|
||||
else {
|
||||
$all_levels = $content
|
||||
}
|
||||
|
||||
$redfish_devices = local_fence_devices('fence_redfish', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_redfish', $redfish_devices, $common_params)
|
||||
$all_levels.each |$index, $levelx_devices |{
|
||||
|
||||
$ipmilan_devices = local_fence_devices('fence_ipmilan', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_ipmilan', $ipmilan_devices, $common_params)
|
||||
if ($enable_instanceha and $is_compute_instanceha_node) {
|
||||
if length($ipmilan_devices) < 1 {
|
||||
fail('You must specify an IPmilan device for a host when configuring instance HA')
|
||||
$level = regsubst($index, 'level', '', 'G')
|
||||
$all_devices = $levelx_devices
|
||||
|
||||
if $::uuid != 'docker' and $::deployment_type != 'containers' {
|
||||
$xvm_devices = local_fence_devices('fence_xvm', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_xvm', $xvm_devices, $common_params)
|
||||
}
|
||||
if length($ipmilan_devices) > 1 {
|
||||
fail('Multiple IPmilan devices for a single host are not supported with instance HA')
|
||||
|
||||
$ironic_devices = local_fence_devices('fence_ironic', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_ironic', $ironic_devices, $common_params)
|
||||
|
||||
$redfish_devices = local_fence_devices('fence_redfish', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_redfish', $redfish_devices, $common_params)
|
||||
|
||||
$ipmilan_devices = local_fence_devices('fence_ipmilan', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_ipmilan', $ipmilan_devices, $common_params)
|
||||
|
||||
$kdump_devices = local_fence_devices('fence_kdump', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_kdump', $kdump_devices, $common_params)
|
||||
|
||||
$rhev_devices = local_fence_devices('fence_rhevm', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_rhevm', $rhev_devices, $common_params)
|
||||
|
||||
$data = {
|
||||
'xvm' => $xvm_devices, 'ironic' => $ironic_devices, 'redfish' => $redfish_devices,
|
||||
'ipmilan' => $ipmilan_devices, 'kdump' => $kdump_devices, 'rhevm' => $rhev_devices
|
||||
}
|
||||
# Get the first (and only) key which is the mac-address
|
||||
$mac = keys($ipmilan_devices)[0]
|
||||
$safe_mac = regsubst($mac, ':', '', 'G')
|
||||
$stonith_resources = [ "stonith-fence_ipmilan-${safe_mac}", 'stonith-fence_compute-fence-nova' ]
|
||||
Pcmk_stonith <||> -> Pcmk_stonith_level <||>
|
||||
pacemaker::stonith::level{ "stonith-level-${safe_mac}":
|
||||
level => 1,
|
||||
target => '$(/usr/sbin/crm_node -n)',
|
||||
stonith_resources => $stonith_resources,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
|
||||
$data.each |$items| {
|
||||
$driver = $items[0]
|
||||
$driver_devices = $items[1]
|
||||
|
||||
if length($driver_devices) == 1 {
|
||||
$mac = keys($driver_devices)[0]
|
||||
$safe_mac = regsubst($mac, ':', '', 'G')
|
||||
if ($enable_instanceha and $is_compute_instanceha_node) {
|
||||
$stonith_resources = [ "stonith-fence_${driver}-${safe_mac}", 'stonith-fence_compute-fence-nova' ]
|
||||
}
|
||||
else {
|
||||
$stonith_resources = [ "stonith-fence_${driver}-${safe_mac}" ]
|
||||
}
|
||||
pacemaker::stonith::level{ "stonith-${level}-${safe_mac}":
|
||||
level => $level,
|
||||
target => '$(/usr/sbin/crm_node -n)',
|
||||
stonith_resources => $stonith_resources,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ironic_devices = local_fence_devices('fence_ironic', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_ironic', $ironic_devices, $common_params)
|
||||
|
||||
$rhev_devices = local_fence_devices('fence_rhevm', $all_devices)
|
||||
create_resources('pacemaker::stonith::fence_rhevm', $rhev_devices, $common_params)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue