From 535989f84746659a80c5588c87a2eb2a0ada1d76 Mon Sep 17 00:00:00 2001 From: Sanjeet Kumar Jha Date: Thu, 18 Jul 2024 11:29:53 +0200 Subject: [PATCH] Adapted the existing checks to work with ascs_ers cluster (#475) * Adapted the existing checks to work with ascs_ers cluster * As advised in the review, I have added line breaks and another else condition at the end which results to false --- priv/catalog/6E9B82.yaml | 30 +++++++++++++++++++++++++++--- priv/catalog/C620DC.yaml | 22 ++++++++++++++++------ priv/catalog/D78671.yaml | 30 +++++++++++++++++++++++++++--- 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/priv/catalog/6E9B82.yaml b/priv/catalog/6E9B82.yaml index 8f9b12b2..6c6cb6fb 100644 --- a/priv/catalog/6E9B82.yaml +++ b/priv/catalog/6E9B82.yaml @@ -48,18 +48,42 @@ remediation: | metadata: target_type: cluster - cluster_type: hana_scale_up + cluster_type: + - hana_scale_up + - ascs_ers facts: - name: corosync_twonode gatherer: corosync.conf@v1 argument: quorum.two_node + - name: corosync_num_nodes + gatherer: corosync.conf@v1 + argument: nodelist.node + + - name: cib_num_nodes + gatherer: cibadmin@v1 + argument: cib.configuration.nodes.node + values: - name: expected_twonode default: 1 + - name: expected_threeormore + default: 0 + expectations: + - name: num_nodes_equal_in_corosync_and_cib + expect: facts.corosync_num_nodes.len == facts.cib_num_nodes.len + failure_message: Number of nodes mentioned in corosync.conf is not equal to number of nodes in cib.xml + - name: twonode_parameter - expect: facts.corosync_twonode == values.expected_twonode - failure_message: Corosync 'two_node' value was expected to be '${values.expected_twonode}' but configured value is '${facts.corosync_twonode}' + expect: | + if facts.corosync_num_nodes.len == 2 { + facts.corosync_twonode == values.expected_twonode + } else if facts.corosync_num_nodes.len >= 3 { + facts.corosync_twonode == values.expected_threeormore + } else { + false + } + failure_message: Corosync 'two_node' value was expected to be 1 when there are 2 nodes and 0 when there 3 or more nodes but configured value is '${facts.corosync_twonode}' when there are '${facts.corosync_num_nodes.len}' number of nodes diff --git a/priv/catalog/C620DC.yaml b/priv/catalog/C620DC.yaml index a5fdcdb2..60fd52e4 100644 --- a/priv/catalog/C620DC.yaml +++ b/priv/catalog/C620DC.yaml @@ -47,18 +47,28 @@ remediation: | metadata: target_type: cluster - cluster_type: hana_scale_up + cluster_type: + - hana_scale_up + - ascs_ers facts: - name: corosync_expected_votes gatherer: corosync.conf@v1 argument: quorum.expected_votes -values: - - name: expected_expected_votes - default: 2 + - name: corosync_num_nodes + gatherer: corosync.conf@v1 + argument: nodelist.node + + - name: cib_num_nodes + gatherer: cibadmin@v1 + argument: cib.configuration.nodes.node expectations: + - name: num_nodes_equal_in_corosync_and_cib + expect: facts.corosync_num_nodes.len == facts.cib_num_nodes.len + failure_message: Number of nodes mentioned in corosync.conf is not equal to number of nodes in cib.xml + - name: expected_votes - expect: facts.corosync_expected_votes == values.expected_expected_votes - failure_message: Corosync 'expected_votes' value was expected to be '${values.expected_expected_votes}' but configured value is '${facts.corosync_expected_votes}' + expect: facts.corosync_expected_votes == facts.corosync_num_nodes.len + failure_message: Corosync 'expected_votes' value was expected to be number of nodes in the cluster but configured value is '${facts.corosync_expected_votes}' diff --git a/priv/catalog/D78671.yaml b/priv/catalog/D78671.yaml index dbf32b29..7a5d7fd3 100644 --- a/priv/catalog/D78671.yaml +++ b/priv/catalog/D78671.yaml @@ -49,18 +49,42 @@ remediation: | metadata: target_type: cluster - cluster_type: hana_scale_up + cluster_type: + - hana_scale_up + - ascs_ers facts: - name: runtime_two_node gatherer: corosync-cmapctl@v1 argument: runtime.votequorum.two_node + - name: corosync_num_nodes + gatherer: corosync.conf@v1 + argument: nodelist.node + + - name: cib_num_nodes + gatherer: cibadmin@v1 + argument: cib.configuration.nodes.node + values: - name: expected_runtime_two_node default: 1 + - name: expected_runtime_threeormore + default: 0 + expectations: + - name: num_nodes_equal_in_corosync_and_cib + expect: facts.corosync_num_nodes.len == facts.cib_num_nodes.len + failure_message: Number of nodes mentioned in corosync.conf and cib.xml are not equal + - name: expectations_two_node - expect: facts.runtime_two_node == values.expected_runtime_two_node - failure_message: Corosync 'two_node' value was expected to be '${values.expected_runtime_two_node}' but value of running config is '${facts.runtime_two_node}' + expect: | + if facts.corosync_num_nodes.len == 2 { + facts.runtime_two_node == values.expected_runtime_two_node + } else if facts.corosync_num_nodes.len >= 3 { + facts.runtime_two_node == values.expected_runtime_threeormore + } else { + false + } + failure_message: Corosync 'two_node' value was expected to be 1 when there are 2 nodes and 0 when there 3 or more nodes but configured value is '${facts.runtime_two_node}' when there are '${facts.corosync_num_nodes.len}' number of nodes