Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: ra: Prevent to add unknown operation (bsc#1236442) #1679

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crmsh/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,6 @@

PCMK_SERVICE = "pacemaker.service"
SBD_SERVICE = "sbd.service"

SANITY_FATAL_RC = 100
# vim:ts=4:sw=4:et:
4 changes: 2 additions & 2 deletions crmsh/ra.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ def sanity_check_op(op, op_dict):
if self.ra_class == "stonith" and op in ("start", "stop"):
return rc
if op not in self.actions():
logger.warning("%s: action '%s' not found in Resource Agent meta-data", ident, op)
rc |= 1
logger.error("Action '%s' not found in Resource Agent meta-data", op)
rc |= constants.SANITY_FATAL_RC
return rc
rc |= sanity_check_op_interval(op, op_dict)
rc |= sanity_check_op_timeout(op, op_dict)
Expand Down
7 changes: 6 additions & 1 deletion crmsh/ui_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ def _verify(self, set_obj_semantic, set_obj_all):
rc1 = set_obj_all.verify()
if config.core.check_frequency != "never":
rc2 = set_obj_semantic.semantic_check(set_obj_all)
if rc2 >= constants.SANITY_FATAL_RC:
raise utils.TerminateSubCommand
else:
rc2 = 0
return rc1 and rc2 <= 1
Expand Down Expand Up @@ -940,7 +942,10 @@ def _commit(self, force=False, replace=False):
rc1 = True
if replace and not force:
rc1 = cib_factory.is_current_cib_equal()
rc2 = self._verify(mkset_obj("xml", "changed"), mkset_obj("xml"))
try:
rc2 = self._verify(mkset_obj("xml", "changed"), mkset_obj("xml"))
except utils.TerminateSubCommand:
return False
if rc1 and rc2:
return cib_factory.commit(replace=replace)
if force or config.core.force:
Expand Down
2 changes: 1 addition & 1 deletion crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
if not can_ask(background_wait):
return False

option_str = "y/n" + "/c" if cancel_option else ""
option_str = "y/n" + ("/c" if cancel_option else "")

Check warning on line 309 in crmsh/utils.py

View check run for this annotation

Codecov / codecov/patch

crmsh/utils.py#L309

Added line #L309 was not covered by tests
msg += ' '
if msg.endswith('? '):
msg = msg[:-2] + f' ({option_str})? '
Expand Down
7 changes: 7 additions & 0 deletions test/features/resource_set.feature
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,10 @@ Feature: Use "crm configure set" to update attributes and operations
And Run "crm configure load xml update /tmp/d.xml" on "hanode1"
And Try "crm configure show|grep -E "^xml <primitive""
Then Expected return code is "1"

@clean
Scenario: Prevent adding unknown operation (bsc#1236442)
When Try "crm configure primitive stateful-1 ocf:pacemaker:Stateful op monitor_Slave interval=10s op monitor_Master interval=5s" on "hanode1"
Then Expected "not found in Resource Agent meta-data" in stderr
When Try "crm configure show stateful-1" on "hanode1"
Then Expected "object stateful-1 does not exist" in stderr