Bug 1867516

Summary: Resource and operation defaults with mixed and-or rules cause an invalid CIB error
Product: Red Hat Enterprise Linux 8 Reporter: Tomas Jelinek <tojeline>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: high    
Version: 8.3CC: cfeist, cluster-maint, idevat, mlisik, mmazoure, mpospisi, nwahl, omular, tojeline
Target Milestone: rc   
Target Release: 8.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.10.6-4.el8 Doc Type: Bug Fix
Doc Text:
Cause: Both 'and' and 'or' operators are used in a rule when creating a new resource or operation defaults set. Consequence: Pcs exits with a 'Unable to update cib' error and the defaults set is not created. Fix: Make sure pcs creates a valid CIB in case both 'and' and 'or' operators are used in a rule. Result: No error, the defaults set is successfully created.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:28:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
proposed fix + tests none

Description Tomas Jelinek 2020-08-10 08:48:58 UTC
Description of problem:
When both 'and' and 'or' operators are used in a rule, pcs creates a CIB improperly causing pacemaker to reject it.


Version-Release number of selected component (if applicable):
pcs-0.10.6-3.el8.


How reproducible:
always, easily


Steps to Reproduce:
pcs resource op defaults set create rule 'resource ::Dummy and (op start or op stop)'


Actual results:
Error: Unable to update cib
Call cib_apply_diff failed (-203): Update does not conform to the configured schema


Expected results:
No error, default set created with the rule.

Comment 3 Tomas Jelinek 2020-08-11 07:52:13 UTC
Created attachment 1711043 [details]
proposed fix + tests

Comment 4 Miroslav Lisik 2020-08-12 09:08:26 UTC
Test:

[root@r8-node-01 rpms]# rpm -q pcs
pcs-0.10.6-4.el8.x86_64

[root@r8-node-01 rpms]# pcs resource op defaults set create rule 'resource ::Dummy and (op start or op stop)'
Warning: Defaults do not apply to resources which override them with their own defined values
[root@r8-node-01 rpms]# echo $?
0
[root@r8-node-01 rpms]# pcs resource op defaults
Meta Attrs: op_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Dummy
    Rule: boolean-op=or score=0
      Expression: op start
      Expression: op stop

Comment 7 Michal Mazourek 2020-08-13 11:29:59 UTC
BEFORE:
=======

[root@virt-125 ~]# rpm -q pcs
pcs-0.10.6-3.el8.x86_64


[root@virt-125 ~]# pcs resource op defaults set create rule 'resource ::Dummy and (op start or op stop)'
Warning: Defaults do not apply to resources which override them with their own defined values
Error: Unable to update cib
Call cib_apply_diff failed (-203): Update does not conform to the configured schema
{cib output}

[root@virt-125 ~]# echo $?
1


AFTER:
======

[root@virt-500 ~]# rpm -q pcs
pcs-0.10.6-4.el8.x86_64


[root@virt-500 ~]# pcs resource op defaults set create rule 'resource ::Dummy and (op start or op stop)'
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-500 ~]# echo $?
0
[root@virt-500 ~]# pcs resource op defaults
Meta Attrs: op_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Dummy
    Rule: boolean-op=or score=0
      Expression: op start
      Expression: op stop


[root@virt-500 ~]# pcs resource op defaults set create rule 'resource ::Dummy and (op start and op stop)'
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-500 ~]# echo $?
0
[root@virt-500 ~]# pcs resource op defaults
Meta Attrs: op_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Dummy
    Rule: boolean-op=or score=0
      Expression: op start
      Expression: op stop
Meta Attrs: op_defaults-meta_attributes-1
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Dummy
    Rule: boolean-op=and score=0
      Expression: op start
      Expression: op stop

> OK


[root@virt-500 ~]# pcs resource op defaults set remove op_defaults-meta_attributes op_defaults-meta_attributes-1


[root@virt-500 ~]# pcs resource op defaults set create rule 'resource ::Dummy and resource ::apache and (op start and op stop)'
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-500 ~]# echo $?
0
[root@virt-500 ~]# pcs resource op defaults
Meta Attrs: op_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Dummy
    Expression: resource ::apache
    Rule: boolean-op=and score=0
      Expression: op start
      Expression: op stop

[root@virt-500 ~]# pcs resource op defaults set create meta m=v rule 'resource ::Stateful and (op start or op stop or op promote)'
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-500 ~]# echo $?
0
[root@virt-500 ~]# pcs resource op defaults
Meta Attrs: op_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Dummy
    Expression: resource ::apache
    Rule: boolean-op=and score=0
      Expression: op start
      Expression: op stop
Meta Attrs: op_defaults-meta_attributes-1
  m=v
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Stateful
    Rule: boolean-op=or score=0
      Expression: op start
      Expression: op stop
      Expression: op promote

> OK


[root@virt-500 ~]# pcs resource op defaults set remove op_defaults-meta_attributes op_defaults-meta_attributes-1


[root@virt-500 ~]# pcs resource op defaults set create rule 'resource ::Stateful and (op start and op stop and (op promote or op demote))'
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-500 ~]# echo $?
0
[root@virt-500 ~]# pcs resource op defaults
Meta Attrs: op_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: resource ::Stateful
    Rule: boolean-op=and score=0
      Expression: op start
      Expression: op stop
      Rule: boolean-op=or score=0
        Expression: op promote
        Expression: op demote


Marking as VERIFIED for pcs-0.10.6-4.el8.

Comment 11 errata-xmlrpc 2020-11-04 02:28:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (pcs bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:4617