Skip to content

Commit 2df9d03

Browse files
committed
Add a rescue operation to handle network-related failures (#96)
1 parent 02276a9 commit 2df9d03

File tree

7 files changed

+34
-14
lines changed

7 files changed

+34
-14
lines changed

docs/HIGH_AVAILABILITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ db_sid: "your-db-sid"
249249
250250
# Boolean indicating if the SCS and database is configured as highly available.
251251
scs_high_availability: true
252-
db_high_availability: true
252+
database_high_availability: true
253253
254254
# The high availability configuration of the SCS and DB instance. Supported values are:
255255
# - AFA (for Azure Fencing Agent)

requirements.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ attrs==25.3.0
2323
# referencing
2424
azure-common==1.1.28
2525
# via azure-mgmt-network
26-
azure-core==1.34.0
26+
azure-core==1.35.0
2727
# via
2828
# azure-identity
2929
# azure-kusto-data
@@ -40,7 +40,7 @@ azure-kusto-data==5.0.4
4040
# azure-kusto-ingest
4141
azure-kusto-ingest==5.0.4
4242
# via -r requirements.in
43-
azure-mgmt-core==1.5.0
43+
azure-mgmt-core==1.6.0
4444
# via azure-mgmt-network
4545
azure-mgmt-network==29.0.0
4646
# via -r requirements.in
@@ -58,7 +58,7 @@ black==25.1.0
5858
# ansible-lint
5959
bracex==2.6
6060
# via wcmatch
61-
certifi==2025.6.15
61+
certifi==2025.7.9
6262
# via requests
6363
cffi==1.17.1
6464
# via cryptography
@@ -68,11 +68,11 @@ click==8.2.1
6868
# via
6969
# -r requirements.in
7070
# black
71-
coverage[toml]==7.9.1
71+
coverage[toml]==7.9.2
7272
# via
7373
# -r requirements.in
7474
# pytest-cov
75-
cryptography==45.0.4
75+
cryptography==45.0.5
7676
# via
7777
# ansible-core
7878
# azure-identity
@@ -144,7 +144,7 @@ packaging==25.0
144144
# ansible-runner
145145
# black
146146
# pytest
147-
pandas==2.3.0
147+
pandas==2.3.1
148148
# via -r requirements.in
149149
pathspec==0.12.1
150150
# via
@@ -241,7 +241,7 @@ tomli==2.2.1
241241
# pytest
242242
tomlkit==0.13.3
243243
# via pylint
244-
typing-extensions==4.14.0
244+
typing-extensions==4.14.1
245245
# via
246246
# astroid
247247
# azure-core

scripts/sap_automation_qa.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,9 @@ run_ansible_playbook() {
301301
local filtered_config
302302
filtered_config=$(get_filtered_test_config)
303303
if [[ -n "$filtered_config" ]]; then
304-
extra_vars="--extra-vars '$filtered_config'"
304+
local temp_config_file=$(mktemp)
305+
echo "$filtered_config" > "$temp_config_file"
306+
extra_vars="--extra-vars @$temp_config_file"
305307
fi
306308
fi
307309

@@ -384,14 +386,14 @@ run_ansible_playbook() {
384386
check_file_exists "$temp_file" \
385387
"Temporary password file not found. Please check the Key Vault secret ID."
386388
command="ansible-playbook ${cmd_dir}/../src/$playbook_name.yml -i $system_hosts \
387-
--extra-vars \"ansible_ssh_pass=$(cat $temp_file)\" --extra-vars @$VARS_FILE -e @$system_params \
389+
--extra-vars 'ansible_ssh_pass=$(cat $temp_file)' --extra-vars @$VARS_FILE -e @$system_params \
388390
-e '_workspace_directory=$system_config_folder' $extra_vars"
389391
else
390392
local password_file="${cmd_dir}/../WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME/password"
391393
check_file_exists "$password_file" \
392394
"password file not found in WORKSPACES/SYSTEM/$SYSTEM_CONFIG_NAME directory."
393395
command="ansible-playbook ${cmd_dir}/../src/$playbook_name.yml -i $system_hosts \
394-
--extra-vars \"ansible_ssh_pass=$(cat $password_file)\" --extra-vars @$VARS_FILE -e @$system_params \
396+
--extra-vars 'ansible_ssh_pass=$(cat $password_file)' --extra-vars @$VARS_FILE -e @$system_params \
395397
-e '_workspace_directory=$system_config_folder' $extra_vars"
396398
fi
397399

@@ -411,11 +413,16 @@ run_ansible_playbook() {
411413
return_code=$?
412414
log "INFO" "Ansible playbook execution completed with return code: $return_code"
413415

414-
# Clean up temporary file if it exists
416+
# Clean up temporary files if they exist
415417
if [[ -n "$temp_file" && -f "$temp_file" ]]; then
416418
rm -f "$temp_file"
417419
log "INFO" "Temporary file deleted: $temp_file"
418420
fi
421+
422+
if [[ -n "$temp_config_file" && -f "$temp_config_file" ]]; then
423+
rm -f "$temp_config_file"
424+
log "INFO" "Temporary config file deleted: $temp_config_file"
425+
fi
419426

420427
exit $return_code
421428
}

src/module_utils/get_pcmk_properties.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def _create_parameter(
165165

166166
if isinstance(expected_value, list):
167167
expected_value = expected_value[0] if expected_value else ""
168+
elif isinstance(expected_value, dict):
169+
expected_value = list(expected_value.values())[0] if expected_value else ""
168170

169171
return Parameters(
170172
category=f"{category}_{subcategory}" if subcategory else category,

src/modules/get_pcmk_properties_scs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def main() -> None:
324324
sid=module.params["sid"],
325325
scs_instance_number=module.params["ascs_instance_number"],
326326
ers_instance_number=module.params["ers_instance_number"],
327-
os_type=OperatingSystemFamily(os_family),
327+
os_type=OperatingSystemFamily(os_family.upper()),
328328
virtual_machine_name=module.params["virtual_machine_name"],
329329
constants=module.params["pcmk_constants"],
330330
fencing_mechanism=module.params["fencing_mechanism"],

src/roles/ha_db_hana/tasks/block-network.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@
203203
ansible.builtin.include_tasks: "roles/misc/tasks/post-validations.yml"
204204

205205
rescue:
206+
- name: "Test Execution Failure: Remove the firewall rule on primary node."
207+
become: true
208+
ansible.builtin.shell: |
209+
iptables -D INPUT -s {{ secondary_node_ip }} -j DROP;
210+
iptables -D OUTPUT -d {{ secondary_node_ip }} -j DROP
211+
register: firewall_rule_deleted
212+
changed_when: firewall_rule_deleted.rc == 0
213+
failed_when: false
214+
when: ansible_hostname == cluster_status_pre.primary_node and
215+
secondary_node_ip is defined
216+
206217
- name: "Rescue operation"
207218
ansible.builtin.include_tasks: "roles/misc/tasks/rescue.yml"
208219

src/roles/ha_scs/tasks/files/constants.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ OS_PARAMETERS:
334334
DEFAULTS:
335335
sysctl:
336336
net.ipv4.tcp_timestamps: "net.ipv4.tcp_timestamps = 0"
337-
vm.swappiness: "vm.swappiness = 60"
337+
vm.swappiness: "vm.swappiness = 10"
338338
corosync-cmapctl:
339339
runtime.config.totem.token: "runtime.config.totem.token (u32) = 30000"
340340
runtime.config.totem.consensus: "runtime.config.totem.consensus (u32) = 36000"

0 commit comments

Comments
 (0)