Skip to content

Commit 020b657

Browse files
authored
Merge pull request #1084 from marcelmamula/ascsers
sap_ha_pacemaker_cluster: Enhance handling of cluster properties and improve ASCS ERS post steps
2 parents bb24c11 + 9cf8712 commit 020b657

13 files changed

Lines changed: 296 additions & 248 deletions

roles/sap_ha_pacemaker_cluster/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,17 @@ sap_ha_pacemaker_cluster_cluster_nodes:
243243
```
244244
### sap_ha_pacemaker_cluster_cluster_properties
245245
- _Type:_ `dict`<br>
246-
- _Default:_ `{'concurrent-fencing': True, 'stonith-enabled': True, 'stonith-timeout': 900}`<br>
247246

248247
Standard pacemaker cluster properties are configured with recommended settings for cluster node fencing.<br>
249248
When no STONITH resource is defined, STONITH will be disabled and a warning displayed.<br>
249+
Default values are predefined by OS and Platform if the variable is not defined.<br>
250+
Some mandatory properties are appended, if not defined.<br>
250251

251252
Example:
252253
```yaml
253254
sap_ha_pacemaker_cluster_cluster_properties:
254-
concurrent-fencing: true
255255
stonith-enabled: true
256-
stonith-timeout: 900
256+
stonith-timeout: 150
257257
```
258258
### sap_ha_pacemaker_cluster_corosync_totem
259259
- _Type:_ `dict`<br>

roles/sap_ha_pacemaker_cluster/defaults/main.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,23 @@ sap_ha_pacemaker_cluster_host_type: "{{ sap_host_type | d(['hana_scaleup_perf'])
5353
### VIP resource default patterns
5454
sap_ha_pacemaker_cluster_vip_client_interface: ''
5555

56-
## A custom stonith definition that takes precedence over platform defaults.
56+
### STONITH
57+
## Recommended fencing methods are defined only for platforms, where applicable.
58+
## It is not recommended to configure cluster without fencing resources (e.g. SBD).
59+
## You can define custom stonith resource using variable 'sap_ha_pacemaker_cluster_stonith_custom'.
60+
## NOTE: Not providing stonith resource will result in cluster property 'stonith-enabled: false'.
5761
# sap_ha_pacemaker_cluster_stonith_custom:
5862
# - name: ""
5963
# agent: "stonith:"
6064
# options:
6165
# pcmk_host_list: ""
6266

63-
# sap_ha_pacemaker_cluster_stonith_custom: []
64-
65-
# Simpler definition format here which gets transformed into the 'ha_cluster' LSR native
66-
# 'ha_cluster_cluster_properties' parameter.
67-
sap_ha_pacemaker_cluster_cluster_properties:
68-
stonith-enabled: true
69-
stonith-timeout: 900
70-
concurrent-fencing: true
67+
## The variable 'sap_ha_pacemaker_cluster_cluster_properties' is used to configure cluster properties (e.g. cib-bootstrap-options).
68+
# NOTE: Default values are defined by Operating System and Platforms, if the variable is not defined.
69+
# Simpler definition format here which gets transformed into the 'ha_cluster' LSR native 'ha_cluster_cluster_properties' parameter.
70+
# sap_ha_pacemaker_cluster_cluster_properties:
71+
# stonith-enabled: true
72+
# stonith-timeout: 150 # Default value 150 is for SBD method.
7173

7274
### Constraints:
7375
# score is dynamic and automatically increased for groups

roles/sap_ha_pacemaker_cluster/meta/argument_specs.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,17 @@ argument_specs:
297297

298298
sap_ha_pacemaker_cluster_cluster_properties:
299299
type: dict
300-
default:
301-
stonith-enabled: true
302-
stonith-timeout: 900
303-
concurrent-fencing: true
304300
description:
305301
- Standard pacemaker cluster properties are configured with recommended settings for
306302
cluster node fencing.
307303
- When no STONITH resource is defined, STONITH will be disabled and a warning displayed.
304+
- Default values are predefined by OS and Platform if the variable is not defined.
305+
- Some mandatory properties are appended, if not defined.
308306

309307
example:
310308
sap_ha_pacemaker_cluster_cluster_properties:
311309
stonith-enabled: true
312-
stonith-timeout: 900
313-
concurrent-fencing: true
310+
stonith-timeout: 150
314311

315312
sap_ha_pacemaker_cluster_corosync_totem:
316313
type: dict

roles/sap_ha_pacemaker_cluster/tasks/configure_nwas_abap_ascs_ers_post_install.yml

Lines changed: 164 additions & 188 deletions
Large diffs are not rendered by default.

roles/sap_ha_pacemaker_cluster/tasks/construct_vars_common.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,23 @@
8888
else __sap_ha_pacemaker_cluster_fence_agent_packages_minimal }}"
8989

9090

91+
# Prepare cluster properties variable with either:
92+
# - User provided 'sap_ha_pacemaker_cluster_cluster_properties' if defined and not empty.
93+
# - Platform specific defaults, if defined.
94+
# - OS specific defaults.
95+
# If the variable 'ha_cluster_properties' is defined, it will append only missing keys.
96+
- name: "SAP HA Prepare Pacemaker - Prepare cluster properties variable"
97+
ansible.builtin.set_fact:
98+
__sap_ha_pacemaker_cluster_cluster_properties:
99+
"{{ sap_ha_pacemaker_cluster_cluster_properties
100+
if sap_ha_pacemaker_cluster_cluster_properties is defined and sap_ha_pacemaker_cluster_cluster_properties | length > 0
101+
else (__sap_ha_pacemaker_cluster_cluster_properties_platform
102+
if __sap_ha_pacemaker_cluster_cluster_properties_platform is defined
103+
else __sap_ha_pacemaker_cluster_cluster_properties_default) }}"
104+
105+
91106
# Prepare corosync totem variable with either:
92-
# - User provided sap_ha_pacemaker_cluster_corosync_totem if present
107+
# - User provided 'sap_ha_pacemaker_cluster_corosync_totem' if present
93108
# - Combine corosync totem from OS variables and Platform variables if present
94109
# - Use default corosync totem from OS variables if Platform variable is not present
95110
- name: "SAP HA Prepare Pacemaker - Prepare corosync totem settings"

roles/sap_ha_pacemaker_cluster/tasks/construct_vars_nwas_abap_ascs_ers_simple_mount.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
- attrs:
7575
- name: resource-stickiness
7676
value: "{{ __sap_ha_pacemaker_cluster_nwas_cs_sapinstance_resource_stickiness }}"
77+
- name: priority
78+
value: 100
7779
operations:
7880
# TODO: Add values for start and stop when they are published.
7981
- action: monitor

roles/sap_ha_pacemaker_cluster/tasks/construct_vars_stonith.yml

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@
3535
)
3636
block:
3737

38+
# Ensure that property 'stonith-enabled' is set to 'false' if no Stonith resources are defined.
39+
# NOTE: We cannot allow user set 'stonith-enabled' 'true' if there are no fencing resources.
3840
- name: "SAP HA Prepare Pacemaker - (STONITH) Set to disabled when no fencing resource is defined"
41+
when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence.
3942
ansible.builtin.set_fact:
40-
sap_ha_pacemaker_cluster_cluster_properties:
41-
"{{ sap_ha_pacemaker_cluster_cluster_properties | combine({'stonith-enabled': false}) }}"
43+
__sap_ha_pacemaker_cluster_cluster_properties:
44+
"{{ __sap_ha_pacemaker_cluster_cluster_properties | combine({'stonith-enabled': false}) }}"
4245

4346
- name: "SAP HA Prepare Pacemaker - Warn that there is no STONITH configured"
4447
ansible.builtin.pause:
@@ -53,38 +56,64 @@
5356
5457
# END of block for disabling stonith
5558

56-
# Add additional stonith properties to sap_ha_pacemaker_cluster_cluster_properties
57-
# Checks if pcmk_delay_max is defined and non zero, then multiples it by 2.
59+
# Stonith cluster properties
60+
# Property 'concurrent-fencing' is 'false' by default, but Scale-Out requires 'true'.
61+
# NOTE: Reversed combine ensures that user defined values are retained.
62+
# TODO: Enable during implementation of Scale-Out.
63+
# - name: "SAP HA Prepare Pacemaker - Disable concurrent-fencing in properties"
64+
# when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence.
65+
# ansible.builtin.set_fact:
66+
# __sap_ha_pacemaker_cluster_cluster_properties:
67+
# "{{ {'concurrent-fencing': true} | combine(__sap_ha_pacemaker_cluster_cluster_properties) }}"
68+
# when:
69+
# - sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleout') | length > 0
70+
71+
72+
# Property 'priority-fencing-delay' is required to ensure proper fencing order.
73+
# The value is based on 'pcmk_delay_max', if it is defined in '__sap_ha_pacemaker_cluster_stonith_default'.
74+
# This task will not change property if it is already defined.
75+
# NOTE: Reversed combine ensures that user defined values are retained.
5876
- name: "SAP HA Prepare Pacemaker - (STONITH) Add priority-fencing-delay property"
77+
when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence.
5978
ansible.builtin.set_fact:
60-
sap_ha_pacemaker_cluster_cluster_properties:
61-
"{{ sap_ha_pacemaker_cluster_cluster_properties | combine({'priority-fencing-delay':
62-
__sap_ha_pacemaker_cluster_stonith_default.options.pcmk_delay_max | int * 2})
63-
if __sap_ha_pacemaker_cluster_stonith_default.options.pcmk_delay_max is defined
64-
and __sap_ha_pacemaker_cluster_stonith_default.options.pcmk_delay_max | int != 0
65-
else sap_ha_pacemaker_cluster_cluster_properties }}"
79+
__sap_ha_pacemaker_cluster_cluster_properties:
80+
"{{ {'priority-fencing-delay': (__pcmk_delay_max | int * 2
81+
if __pcmk_delay_max is defined and __pcmk_delay_max | int != 0
82+
else 30)} | combine(__sap_ha_pacemaker_cluster_cluster_properties)
83+
if __sap_ha_pacemaker_cluster_cluster_properties['priority-fencing-delay'] is not defined
84+
else __sap_ha_pacemaker_cluster_cluster_properties }}"
85+
vars:
86+
__pcmk_delay_max:
87+
"{{ (__sap_ha_pacemaker_cluster_stonith_default['instance_attrs'][0]['attrs']
88+
| selectattr('name', 'equalto', 'pcmk_delay_max') | first).value }}"
6689

67-
- name: "SAP HA Prepare Pacemaker - (STONITH) Define cluster properties"
90+
# Ensure that property 'concurrent-fencing' is set to 'true' for Azure.
91+
# Source: https://learn.microsoft.com/en-us/azure/sap/workloads/high-availability-guide-suse-pacemaker?tabs=msi#create-a-fencing-device-on-the-pacemaker-cluster
92+
# NOTE: Reversed combine ensures that user defined values are retained.
93+
- name: "SAP HA Prepare Pacemaker - (STONITH) - MSAZURE VM - Add cluster property 'concurrent-fencing'"
6894
when:
69-
- sap_ha_pacemaker_cluster_cluster_properties is defined
70-
- sap_ha_pacemaker_cluster_cluster_properties is iterable
71-
- sap_ha_pacemaker_cluster_cluster_properties | length > 0
95+
- ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence.
96+
- __sap_ha_pacemaker_cluster_platform == "cloud_msazure_vm"
7297
ansible.builtin.set_fact:
73-
__sap_ha_pacemaker_cluster_cluster_properties: "{{ __sap_ha_pacemaker_cluster_cluster_properties | d([]) + __stonith_properties }}"
74-
vars:
75-
__stonith_properties:
98+
__sap_ha_pacemaker_cluster_cluster_properties:
99+
"{{ {'concurrent-fencing': true} | combine(__sap_ha_pacemaker_cluster_cluster_properties) }}"
100+
101+
102+
# Prepare structure compatible with the variable 'ha_cluster_cluster_properties'.
103+
- name: "SAP HA Prepare Pacemaker - (STONITH) Define cluster properties"
104+
# This task is skipped if 'ha_cluster_cluster_properties' is defined, as both structures are different.
105+
when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence.
106+
ansible.builtin.set_fact:
107+
__sap_ha_pacemaker_cluster_cluster_properties:
76108
- attrs: |-
77-
{% set attrs = __sap_ha_pacemaker_cluster_cluster_properties | map(attribute='attrs') | flatten -%}
78-
{%- for default_cluster_properties in (sap_ha_pacemaker_cluster_cluster_properties | dict2items) -%}
79-
{% if default_cluster_properties.key not in
80-
(__sap_ha_pacemaker_cluster_cluster_properties | map(attribute='attrs') | flatten | map(attribute='name')) -%}
81-
{% set role_attrs = attrs.extend([
82-
{
83-
'name': default_cluster_properties.key,
84-
'value': default_cluster_properties.value
85-
}
86-
]) -%}
87-
{%- endif %}
109+
{% set attrs = [] -%}
110+
{%- for default_cluster_properties in (__sap_ha_pacemaker_cluster_cluster_properties | dict2items) -%}
111+
{% set role_attrs = attrs.extend([
112+
{
113+
'name': default_cluster_properties.key,
114+
'value': default_cluster_properties.value
115+
}
116+
]) -%}
88117
{%- endfor %}
89118
{{ attrs }}
90119

roles/sap_ha_pacemaker_cluster/tasks/include_vars_hana.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@
2323
- "(role_path + '/vars/' + include_item + '.yml') is file"
2424

2525

26-
# Disable concurrent-fencing for Scale-up scenario.
27-
# This assignment cannot be in scaleup var file, because it results in nested error.
28-
- name: "SAP HA Prepare Pacemaker - Disable concurrent-fencing in properties"
29-
ansible.builtin.set_fact:
30-
sap_ha_pacemaker_cluster_cluster_properties:
31-
"{{ sap_ha_pacemaker_cluster_cluster_properties | combine({'concurrent-fencing': false})
32-
if sap_ha_pacemaker_cluster_cluster_properties['concurrent-fencing'] is defined
33-
else sap_ha_pacemaker_cluster_cluster_properties }}"
34-
when:
35-
- sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleup') | length > 0
36-
37-
3826
# Private variables are assigned following logic:
3927
# 1. Use backwards compatible var if new var is empty
4028
# 2. Use user input if new var is not empty

roles/sap_ha_pacemaker_cluster/vars/RedHat.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ __sap_ha_pacemaker_cluster_command:
5555
resource_restart: "pcs resource restart"
5656
resource_cleanup: "pcs resource cleanup"
5757

58+
# Dictionary with default cluster properties
59+
__sap_ha_pacemaker_cluster_cluster_properties_default:
60+
stonith-enabled: true
61+
stonith-timeout: 150 # Default value 150 is for SBD method.
62+
5863
# Default corosync options - OS specific
5964
__sap_ha_pacemaker_cluster_corosync_totem_default:
6065
options: {}

roles/sap_ha_pacemaker_cluster/vars/Suse.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ __sap_ha_pacemaker_cluster_connector_config_lines:
1212
- "service/halib_cluster_connector = /usr/bin/sap_suse_cluster_connector"
1313

1414
# Cluster commands to manage resources - crmsh commands in SUSE OS family.
15+
# --force is required only for resource restart and maintenance on/off.
1516
__sap_ha_pacemaker_cluster_command:
1617
resource_stop: "crm resource stop"
1718
resource_start: "crm resource start"
18-
resource_restart: "crm resource restart"
19+
resource_restart: "crm --force resource restart"
1920
resource_cleanup: "crm resource cleanup"
2021

22+
# Dictionary with default cluster properties
23+
__sap_ha_pacemaker_cluster_cluster_properties_default:
24+
stonith-enabled: true
25+
stonith-timeout: 150 # Default value 150 is for SBD method.
26+
2127
# Default corosync options - OS specific
2228
__sap_ha_pacemaker_cluster_corosync_totem_default:
2329
options:

0 commit comments

Comments
 (0)