Skip to content

Commit

Permalink
[crmsh-4.5] Fix: cibconfig: Disable auto add advise values for operat…
Browse files Browse the repository at this point in the history
…ions (bsc#1231386) (#1578)

 - Dev: Add option core.has_ra_advised_op;
- Since this auto-add feature might surprise users, we should disable it
by setting the option 'has_ra_advised_op' value to 'no'.
  • Loading branch information
liangxin1300 authored Oct 12, 2024
2 parents 16b5eae + 07bf723 commit eb5e2e1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
20 changes: 11 additions & 9 deletions crmsh/cibconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def id_for_node(node, id_hint=None):
return obj_id


def postprocess_cli(node, oldnode=None, id_hint=None, complete_advised=False):
def postprocess_cli(node, oldnode=None, id_hint=None, promotable_default_meta=False):
"""
input: unprocessed but parsed XML
output: XML, obj_type, obj_id
Expand All @@ -816,14 +816,14 @@ def postprocess_cli(node, oldnode=None, id_hint=None, complete_advised=False):
resolve_references(node)
if oldnode is not None:
remove_id_used_attributes(oldnode)
if complete_advised:
complete_advised_meta(node)
if promotable_default_meta:
add_promotable_default_meta_attr(node)
return node, obj_type, obj_id


def complete_advised_meta(node):
def add_promotable_default_meta_attr(node):
"""
Complete advised meta attributes
Add promotable default advised meta attributes
"""
if node.tag != "clone":
return
Expand Down Expand Up @@ -855,21 +855,23 @@ def parse_cli_to_xml(cli, oldnode=None):
output: XML, obj_type, obj_id
"""
node = None
complete = False
has_ra_advised_op = False
default_promotable_meta = False
comments = []
if isinstance(cli, str):
utils.auto_convert_role = False
for s in lines2cli(cli):
node = parse.parse(s, comments=comments)
else: # should be a pre-tokenized list
utils.auto_convert_role = True
complete = True
node = parse.parse(cli, comments=comments, ignore_empty=False, complete_advised=complete)
has_ra_advised_op = config.core.has_ra_advised_op
default_promotable_meta = True
node = parse.parse(cli, comments=comments, ignore_empty=False, complete_advised=has_ra_advised_op)
if node is False:
return None, None, None
elif node is None:
return None, None, None
return postprocess_cli(node, oldnode, complete_advised=complete)
return postprocess_cli(node, oldnode, promotable_default_meta=default_promotable_meta)

#
# cib element classes (CibObject the parent class)
Expand Down
1 change: 1 addition & 0 deletions crmsh/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def get(self, value):
'lock_timeout': opt_string('120'),
'no_ssh': opt_boolean('no'),
'OCF_1_1_SUPPORT': opt_boolean('no'),
'has_ra_advised_op': opt_boolean('no'),
'obscure_pattern': opt_string('passw*')
},
'path': {
Expand Down
1 change: 1 addition & 0 deletions etc/crm.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
; report_tool_options =
; lock_timeout = 120
; no_ssh = no
; has_ra_advised_op = no

; set OCF_1_1_SUPPORT to yes is to fully turn on OCF 1.1 feature once the corresponding CIB detected.
; OCF_1_1_SUPPORT = yes
Expand Down
11 changes: 0 additions & 11 deletions test/features/cluster_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ Feature: Functional test to cover SAP clusterAPI
And Show cluster status on "hanode1"
When Run "su - hacluster -c 'crm configure show'" on "hanode1"
Then Expected return code is "0"
And Expected multiple lines in output
"""
primitive d2 Dummy \
params fake=test \
meta resource-stickiness=5000 \
op monitor interval=10s timeout=20s on-fail=restart \
op start timeout=20s interval=0s \
op stop timeout=20s interval=0s
group g d2 \
meta resource-stickiness=3000
"""

@clean
Scenario: pacemaker ACL related operations by hacluster
Expand Down
4 changes: 2 additions & 2 deletions test/features/crm_report_bugs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ Feature: crm report functional test for verifying bugs

@clean
Scenario: crm report collect trace ra log
When Run "crm configure primitive d Dummy" on "hanode1"
And Run "crm configure primitive d2 Dummy" on "hanode1"
When Run "crm configure primitive d Dummy op monitor interval=10s" on "hanode1"
And Run "crm configure primitive d2 Dummy op monitor interval=10s" on "hanode1"
Then Resource "d" is started on "hanode1"
And Resource "d2" is started on "hanode2"
When Run "crm resource trace d monitor" on "hanode1"
Expand Down
1 change: 1 addition & 0 deletions test/run-functional-tests
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ adjust_test_case() {
run_origin_regression_test() {
CONFIG_COROSYNC_FLAG=0
setup_cluster "hanode1"
docker_exec "hanode1" "echo -e '[core]\nhas_ra_advised_op = yes' > /etc/crm/crm.conf"
docker_exec "hanode1" "sh /usr/share/crmsh/tests/regression.sh"
return $?
}
Expand Down

0 comments on commit eb5e2e1

Please sign in to comment.