RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1862966 - [RFE] Full rules support in resource and operation defaults
Summary: [RFE] Full rules support in resource and operation defaults
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: pcs
Version: 8.3
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: 8.4
Assignee: Tomas Jelinek
QA Contact: cluster-qe@redhat.com
Steven J. Levine
URL:
Whiteboard:
Depends On: 1817547
Blocks: 1250744 2019471
TreeView+ depends on / blocked
 
Reported: 2020-08-03 10:43 UTC by Tomas Jelinek
Modified: 2021-11-02 15:51 UTC (History)
9 users (show)

Fixed In Version: pcs-0.10.7-1.el8
Doc Type: Enhancement
Doc Text:
Feature: Support node attribute expressions and date expressions in resource and operation defaults rules. Reason: The first implementation of resource and operation defaults only supported 'resource' and 'op' expressions, including 'and' and 'or' operators and parenthesis. With this patch, all other rule expressions are fully supported. Result: All rule expressions provided by Pacemaker are fully supported in 'pcs resource defaults set create rule' and 'pcs resource op defaults set create rule' commands. By default, pcs does not list expired resources and operations defaults sets. To list all sets, use the --all flag: 'pcs resource [op] defaults config --all'. To skip evaluating rules and speed up the listing, use the --no-expire-check flag: 'pcs resource [op] defaults config --no-expire-check'.
Clone Of:
Environment:
Last Closed: 2021-05-18 15:12:08 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
proposed fix + tests part1 (200.52 KB, patch)
2020-09-18 14:16 UTC, Tomas Jelinek
no flags Details | Diff
proposed fix + tests part2 (79.92 KB, patch)
2020-09-18 14:16 UTC, Tomas Jelinek
no flags Details | Diff
proposed fix + tests part3 (184.67 KB, patch)
2020-09-18 14:16 UTC, Tomas Jelinek
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1222691 0 low CLOSED "rule date in_range to <date>" should be valid syntax 2023-06-16 09:16:02 UTC
Red Hat Bugzilla 1500082 0 unspecified CLOSED [RFE] Support value-source option for node attribute rule expressions 2021-02-22 00:41:40 UTC

Description Tomas Jelinek 2020-08-03 10:43:33 UTC
Description of problem:
Support for resource and operation defaults with rules has been added in bz1817547. In order to provide the feature in time, only the most crucial rule expressions (resource, op, and, or, parenthesis) have been implemented. The purpose of this bz is to implement all the other rule expressions supported by pacemaker already.

Since bz1250744 requires those rule expressions to be supported by pcs, this is a blocker for bz1250744.


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


How reproducible:
always, easily


Steps to Reproduce:
Try to use defined|not_defined, lt|gt|lte|gte|eq|ne, date or date-spec expressions in 'pcs resource [op] defaults' commands.


Actual results:
Rules containing said expressions are not accepted by pcs.


Expected results:
Rules containing said expressions are accepted by pcs.

Comment 2 Tomas Jelinek 2020-09-18 14:16:23 UTC
Created attachment 1715377 [details]
proposed fix + tests part1

Comment 3 Tomas Jelinek 2020-09-18 14:16:38 UTC
Created attachment 1715378 [details]
proposed fix + tests part2

Comment 4 Tomas Jelinek 2020-09-18 14:16:52 UTC
Created attachment 1715379 [details]
proposed fix + tests part3

Comment 5 Tomas Jelinek 2020-09-18 14:31:21 UTC
Following rule expressions are now supported in 'pcs resource defaults set create rule' and 'pcs resource op defaults set create rule' commands:
defined|not_defined <node attribute>
<node attribute> lt|gt|lte|gte|eq|ne [string|integer|number|version] <value>
date gt|lt <date>
date in_range [<date>] to <date>
date in_range <date> to duration <duration options>
date-spec <date-spec options>

CLI tests:
https://github.com/ClusterLabs/pcs/blob/d7ec6d4184dc5bbaf7fb0f7ccafb77d3321cb86c/pcs_test/tier1/test_cib_options.py#L365-L478
https://github.com/ClusterLabs/pcs/blob/d7ec6d4184dc5bbaf7fb0f7ccafb77d3321cb86c/pcs_test/tier1/test_cib_options.py#L82-L167


Expired rules support:
By default, pcs does not list expired resources and operations defaults sets. To list all sets, use the --all flag: 'pcs resource [op] defaults config --all'. To skip evaluating rules and speed up the listing, use the --no-expire-check flag: 'pcs resource [op] defaults config --no-expire-check'.

CLI tests:
https://github.com/ClusterLabs/pcs/blob/d7ec6d4184dc5bbaf7fb0f7ccafb77d3321cb86c/pcs_test/tier1/test_cib_options.py#L169-L246

Comment 8 Miroslav Lisik 2020-10-14 14:01:57 UTC
Test:

[root@r8-node-01 ~]# rpm -q pcs
pcs-0.10.7-1.el8.x86_64

[root@r8-node-01 ~]# pcs resource defaults set create id=mine score=10 meta nam1=val1 nam2=val2 \
>     rule \(defined attr1 or attr2 gte number 12 \
>     or attr3 lt version 3.2.1 \
>     or attr4 ne string test \
>     or attr5 lt 3\)\
>     and \(date gt 2018-05-17T13:28:19\
>     or date in_range 2019-01-01 to 2019-03-15 \
>     or date in_range 2019-05-01 to duration months=2 \
>     or date-spec years=2019 months=7-8 weekdays=6-7 \
>     or date in_range to 2019-12-15\)
Warning: Defaults do not apply to resources which override them with their own defined values
[root@r8-node-01 ~]# pcs resource defaults
Meta Attrs: mine score=10
  nam1=val1
  nam2=val2
  Rule: boolean-op=and score=INFINITY
    Rule: boolean-op=or score=0
      Expression: defined attr1
      Expression: attr2 gte number 12
      Expression: attr3 lt version 3.2.1
      Expression: attr4 ne string test
      Expression: attr5 lt 3
    Rule: boolean-op=or score=0
      Expression: date gt 2018-05-17T13:28:19
      Expression: date in_range 2019-01-01 to 2019-03-15
      Expression: date in_range 2019-05-01 to duration
        Duration: months=2
      Expression:
        Date Spec: months=7-8 weekdays=6-7 years=2019
      Expression: date in_range to 2019-12-15

Comment 11 Michal Mazourek 2020-11-05 16:22:49 UTC
AFTER:
======

[root@virt-134 ~]# rpm -q pcs
pcs-0.10.7-1.el8.x86_64


[root@virt-134 ~]# pcs resource defaults set create --help

Usage: pcs resource defaults set create...
    defaults set create [<set options>] [meta [<name>=<value>]...]
            [rule [<expression>]]
        Create a new set of default values for resources. You may specify a rule
        describing resources to which the set applies.

        Set options are: id, score

        Expression looks like one of the following:
          resource [<standard>]:[<provider>]:[<type>]
          defined|not_defined <node attribute>
          <node attribute> lt|gt|lte|gte|eq|ne [string|integer|number|version]
              <value>
          date gt|lt <date>
          date in_range [<date>] to <date>
          date in_range <date> to duration <duration options>
          date-spec <date-spec options>
          <expression> and|or <expression>
          (<expression>)

        You may specify all or any of 'standard', 'provider' and 'type' in
        a resource expression. For example: 'resource ocf::' matches all
        resources of 'ocf' standard, while 'resource ::Dummy' matches all
        resources of 'Dummy' type regardless of their standard and provider.

        Dates are expected to conform to ISO 8601 format.

        Duration options are: hours, monthdays, weekdays, yearsdays, months,
        weeks, years, weekyears, moon. Value for these options is an integer.

        Date-spec options are: hours, monthdays, weekdays, yearsdays, months,
        weeks, years, weekyears, moon. Value for these options is an integer or
        a range written as integer-integer.

        NOTE: Defaults do not apply to resources which override them with their
        own defined values.


[root@virt-134 ~]# pcs resource op defaults set create --help

Usage: pcs resource op defaults set create...
    op defaults set create [<set options>] [meta [<name>=<value>]...]
            [rule [<expression>]]
        Create a new set of default values for resource operations. You may
        specify a rule describing resources and / or operations to which the set
        applies.

        Set options are: id, score

        Expression looks like one of the following:
          op <operation name> [interval=<interval>]
          resource [<standard>]:[<provider>]:[<type>]
          defined|not_defined <node attribute>
          <node attribute> lt|gt|lte|gte|eq|ne [string|integer|number|version]
              <value>
          date gt|lt <date>
          date in_range [<date>] to <date>
          date in_range <date> to duration <duration options>
          date-spec <date-spec options>
          <expression> and|or <expression>
          (<expression>)

        You may specify all or any of 'standard', 'provider' and 'type' in
        a resource expression. For example: 'resource ocf::' matches all
        resources of 'ocf' standard, while 'resource ::Dummy' matches all
        resources of 'Dummy' type regardless of their standard and provider.

        Dates are expected to conform to ISO 8601 format.

        Duration options are: hours, monthdays, weekdays, yearsdays, months,
        weeks, years, weekyears, moon. Value for these options is an integer.

        Date-spec options are: hours, monthdays, weekdays, yearsdays, months,
        weeks, years, weekyears, moon. Value for these options is an integer or
        a range written as integer-integer.

        NOTE: Defaults do not apply to resources which override them with their
        own defined values.

> OK: new expressions are well documented


1. Testing node attributes expressions for resource defaults and resource op defaults

## Preparing node attribute
[root@virt-134 ~]# pcs node attribute virt-135 test_attr=100
[root@virt-134 ~]# pcs node attribute virt-134 test_attr=50
[root@virt-134 ~]# pcs node attribute
Node Attributes:
 virt-134: test_attr=50
 virt-135: test_attr=100


## Creating default rules with 'defined' attribute 'test_attr' for dummy resource

[root@virt-134 ~]# pcs resource defaults set create id=res_defined score=10 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and defined test_attr
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_defined score=10
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: defined test_attr

> Syntax for resource defaults OK

[root@virt-134 ~]# pcs resource op defaults set create id=op_defined score=10 meta timeout=5s rule op monitor and resource ocf:heartbeat:Dummy and defined test_attr
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource op defaults
Meta Attrs: op_defined score=10
  timeout=5s
  Rule: boolean-op=and score=INFINITY
    Expression: op monitor
    Expression: resource ocf:heartbeat:Dummy
    Expression: defined test_attr

> Syntax for operation defaults OK

## fucntionality check (this rule should apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> FAIL: Default rule with resource stickiness did not apply for ocf:heartbeat:Dummy (d2), which moved from virt-135 after d1 was moved there. The rule should apply and d2 resource should have stayed on virt-135. This problem is with all node attributes expressions and has been reported as bz1891929


[root@virt-134 ~]# pcs resource op defaults set remove res_defined
[root@virt-134 ~]# pcs resource op defaults set remove op_defined


2. Testing 'date gt|lt <date>' for resource defaults and resource op defaults

[root@virt-134 ~]# date
Thu 22 Oct 10:24:53 CEST 2020


## Creating default rule with date lt date in the future for dummy resource

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date lt 2020-10-23
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults 
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date lt 2020-10-23

> Syntax for resource defaults OK

[root@virt-134 ~]# pcs resource op defaults set create id=op_def score=10 meta timeout=5s rule op monitor and resource ocf:heartbeat:Dummy and date lt 2020-10-23
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource op defaults
Meta Attrs: op_def score=10
  timeout=5s
  Rule: boolean-op=and score=INFINITY
    Expression: op monitor
    Expression: resource ocf:heartbeat:Dummy
    Expression: date lt 2020-10-23

> Syntax for operation defaults OK

## functionality check (this rule should apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness applied for ocf:heartbeat:Dummy (d2), which didn't move from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def
[root@virt-134 ~]# pcs resource op defaults set remove op_def


## Creating default rule with date gt date in the future for dummy resource

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date gt 2020-10-23
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs (not yet in effect): res_def score=1
  resource-stickiness=100
  Rule (not yet in effect): boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date gt 2020-10-23

## functionality check (this rule should not apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness did not apply for ocf:heartbeat:Dummy (d2), which moved from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def


## Creating default rule with date in the past 

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date lt 2020-10-21
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults

[root@virt-134 ~]# echo $?
0

[root@virt-134 ~]# pcs cluster cib | grep \<rsc_defaults\> -A 8
    <rsc_defaults>
      <meta_attributes id="res_def" score="1">
        <rule boolean-op="and" id="res_def-rule" score="INFINITY">
          <rsc_expression id="res_def-rule-rsc-ocf-heartbeat-Dummy" class="ocf" provider="heartbeat" type="Dummy"/>
          <date_expression id="res_def-rule-expr" operation="lt" end="2020-10-21"/>
        </rule>
        <nvpair id="res_def-resource-stickiness" name="resource-stickiness" value="100"/>
      </meta_attributes>
    </rsc_defaults>

> OK: Date in the past, which can't apply (date lt date in the past) is not shown in the list, however still exists in the cib (message 'No defaults set' is not present in this case)

[root@virt-134 ~]# pcs resource defaults set remove res_def

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date gt 2020-10-21
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults 
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date gt 2020-10-21

> OK: Date in the past, which apply (date gt date in the past) is shown in the list

[root@virt-134 ~]# pcs resource defaults set remove res_def


## Testing invalid date inputs

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date lt 2020-10-2
Error: '2020-10-2' is not a valid date value, use ISO 8601 date
Error: Errors have occurred, therefore pcs is unable to continue
[root@virt-134 ~]# echo $?
1
[root@virt-134 ~]# pcs resource defaults
No defaults set

> OK

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date lt 2020-13-20
Error: '2020-13-20' is not a valid date value, use ISO 8601 date
Error: Errors have occurred, therefore pcs is unable to continue
[root@virt-134 ~]# echo $?
1
[root@virt-134 ~]# pcs resource defaults
No defaults set

> OK

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date at 2020-13-20
Error: 'resource ocf:heartbeat:Dummy and date at 2020-13-20' is not a valid rule expression, parse error near or after line 1 column 30
  resource ocf:heartbeat:Dummy and date at 2020-13-20
  -----------------------------^
Error: Errors have occurred, therefore pcs is unable to continue
[root@virt-134 ~]# echo $?
1
[root@virt-134 ~]# pcs resource defaults
No defaults set

> OK

[root@virt-134 ~]# pcs resource op defaults set create id=op_def score=10 meta timeout=5s rule op monitor and resource ocf:heartbeat:Dummy and date lt 2020-13-20
Error: '2020-13-20' is not a valid date value, use ISO 8601 date
Error: Errors have occurred, therefore pcs is unable to continue
[root@virt-134 ~]# echo $?
1
[root@virt-134 ~]# pcs resource op defaults
No defaults set

> OK
 

3. Testing 'date in_range [<date>] to <date>' for resource defaults and resource op defaults

[root@virt-134 ~]# date
Thu 22 Oct 13:28:07 CEST 2020

## Creating default rule 'date in range <date> to <date>' where present date is within the entered range for dummy resource

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date in_range 2020-10-22T13:00:00 to 2020-10-22T18:00:00
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date in_range 2020-10-22T13:00:00 to 2020-10-22T18:00:00

> Syntax for resource defaults OK

[root@virt-134 ~]# pcs resource op defaults set create id=op_def score=10 meta timeout=5s rule op monitor and resource ocf:heartbeat:Dummy and date in_range 2020-10-22T13:00:00 to 2020-10-22T18:00:00
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource op defaults
Meta Attrs: op_def score=10
  timeout=5s
  Rule: boolean-op=and score=INFINITY
    Expression: op monitor
    Expression: resource ocf:heartbeat:Dummy
    Expression: date in_range 2020-10-22T13:00:00 to 2020-10-22T18:00:00

> Syntax for operation defaults OK

## functionality check (this rule should apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness applied for ocf:heartbeat:Dummy (d2), which didn't move from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def
[root@virt-134 ~]# pcs resource defaults set remove res_def


## Creating default rule 'date in range <date> to <date>' where present date is not within the entered range, which is in the future, for dummy resource

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date in_range 2020-10-23 to 2020-10-24
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs (not yet in effect): res_def score=1
  resource-stickiness=100
  Rule (not yet in effect): boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date in_range 2020-10-23 to 2020-10-24

> OK: Rule, which should not apply is still present in the list, as it will apply in the future

## functionality check (this rule should not apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness did not apply for ocf:heartbeat:Dummy (d2), which moved from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def


## Creating default rule 'date in range <date> to <date>' where present date is not within the entered range, which is in the past, for dummy resource

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date in_range 2020-01-23 to 2020-01-24
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults

> OK: The past date which should not apply is not even present in the list, but still is in cib

## functionality check (this rule should not apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness did not apply for ocf:heartbeat:Dummy (d2), which moved from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def


## Creating rule 'date in_range [<date>] to <date>', where is the first <date> ommited. bz1222691 covers this issue in depth

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date in_range to 2020-10-23
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date in_range to 2020-10-23

## functionality check (this rule should apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness applied for ocf:heartbeat:Dummy (d2), which didn't move from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def


4. Testing 'date in_range <date> to duration <duration options>' for resource defaults and resource op defaults

[root@virt-134 ~]# date
Fri 23 Oct 12:34:20 CEST 2020


## Creating rule, that will apply in future for duration of one hour

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date in_range 2020-10-23T12:50:00 to duration hours=1
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults 
Meta Attrs (not yet in effect): res_def score=1
  resource-stickiness=100
  Rule (not yet in effect): boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date in_range 2020-10-23T12:50:00 to duration
      Duration: hours=1

> Syntax for resource defaults OK

[root@virt-134 ~]# pcs resource op defaults set create id=op_def score=10 meta timeout=5s rule op monitor and resource ocf:heartbeat:Dummy and date in_range 2020-10-23T12:50:00 to duration hours=1
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource op defaults
Meta Attrs (not yet in effect): op_def score=10
  timeout=5s
  Rule (not yet in effect): boolean-op=and score=INFINITY
    Expression: op monitor
    Expression: resource ocf:heartbeat:Dummy
    Expression: date in_range 2020-10-23T12:50:00 to duration
      Duration: hours=1

> Syntax for operation defaults OK

## functionality check (this rule should not apply yet)

[root@virt-134 ~]# date
Fri 23 Oct 12:38:09 CEST 2020

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness did not apply for ocf:heartbeat:Dummy (d2), which moved from virt-135 after d1 was moved there.


## Keeping the same rule, but with time within the entered duration

[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: date in_range 2020-10-23T12:50:00 to duration
      Duration: hours=1

[root@virt-134 ~]# date
Fri 23 Oct 13:04:36 CEST 2020

## functionality check (this rule should apply now)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness applied for ocf:heartbeat:Dummy (d2), which didn't move from virt-135 after d1 was moved there.


## Keeping te same rule, but with expired duration

[root@virt-134 ~]# pcs resource defaults

[root@virt-134 ~]# date
Fri 23 Oct 14:03:34 CEST 2020

> Expired rule is not visible in the list

## functionality check (this rule shoud not apply anymore)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness did not apply for ocf:heartbeat:Dummy (d2), which moved from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def
[root@virt-134 ~]# pcs resource op defaults set remove op_def


## Creating rule with various duration options

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and \(date in_range 2020-10-23T12:50:00 to duration hours=1 or date in_range 2020-10-23T12:50:00 to duration monthdays=5 or date in_range 2020-10-23T12:50:00 to duration weekdays=1 or date in_range 2020-10-23T12:50:00 to duration months=10 or date in_range 2020-10-23T12:50:00 to duration years=1\)
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Rule: boolean-op=or score=0
      Expression: date in_range 2020-10-23T12:50:00 to duration
        Duration: hours=1
      Expression: date in_range 2020-10-23T12:50:00 to duration
        Duration: monthdays=5
      Expression: date in_range 2020-10-23T12:50:00 to duration
        Duration: weekdays=1
      Expression: date in_range 2020-10-23T12:50:00 to duration
        Duration: months=10
      Expression: date in_range 2020-10-23T12:50:00 to duration
        Duration: years=1

> Resource default syntax OK

## functionality check (this rule should apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness applied for ocf:heartbeat:Dummy (d2), which didn't move from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def


5. Testing 'date-spec <date-spec options>' for resource defaults and resource op defaults

[root@virt-134 ~]# date
Mon 26 Oct 12:03:20 CET 2020


## Creating rule where current date is within date-spec

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date-spec hours=11-13
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression:
      Date Spec: hours=11-13

> Syntax for resource defaults OK

[root@virt-134 ~]# pcs resource op defaults set create id=op_def score=10 meta timeout=5s rule op monitor and resource ocf:heartbeat:Dummy and date-spec hours=11-13
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource op defaults
Meta Attrs: op_def score=10
  timeout=5s
  Rule: boolean-op=and score=INFINITY
    Expression: op monitor
    Expression: resource ocf:heartbeat:Dummy
    Expression:
      Date Spec: hours=11-13

> Syntax for operation defaults OK

## functionality check (this rule should apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness applied for ocf:heartbeat:Dummy (d2), which didn't move from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def
[root@virt-134 ~]# pcs resource op defaults set remove op_def


## Creating rule where current date is not within date-spec

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date-spec monthdays=1-25
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression:
      Date Spec: monthdays=1-25

## functionality check (this rule should not apply)
 
+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness did not apply for ocf:heartbeat:Dummy (d2), which moved from virt-135 after d1 was moved there.

[root@virt-134 ~]# pcs resource defaults set remove res_def


## Creating rule with various date-spec options

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=1 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and date-spec hours=8-16 monthdays=1-28 weekdays=1-5 months=10-12 years=2020 
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults 
Meta Attrs: res_def score=1
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression:
      Date Spec: hours=8-16 monthdays=1-28 months=10-12 weekdays=1-5 years=2020

> Syntax OK

[root@virt-134 ~]# date
Mon 26 Oct 15:27:45 CET 2020

## functionality check (this rule should apply)

+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource delete d1
Attempting to stop: d1... Stopped
+ pcs resource delete d2
Attempting to stop: d2... Stopped

> OK: Default rule with resource stickiness applied for ocf:heartbeat:Dummy (d2), which didn't move from virt-135 after d1 was moved there.


6. Trying multiple expressions at once

[root@virt-134 ~]# pcs resource defaults set create id=res_def score=10 meta resource-stickiness=100 rule \(defined attr1 or attr2 gte number 12 or attr3 lt version 3.2.1 or attr4 ne string test or attr5 lt 3\) and \(date gt 2018-05-17T13:28:19 or date in_range 2019-01-01 to 2019-03-15 or date in_range 2019-05-01 to duration months=2 or date-spec years=2019 months=7-8 weekdays=6-7 or date in_range to 2019-12-15\)
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_def score=10
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Rule: boolean-op=or score=0
      Expression: defined attr1
      Expression: attr2 gte number 12
      Expression: attr3 lt version 3.2.1
      Expression: attr4 ne string test
      Expression: attr5 lt 3
    Rule: boolean-op=or score=0
      Expression: date gt 2018-05-17T13:28:19
      Expression: date in_range 2019-01-01 to 2019-03-15
      Expression: date in_range 2019-05-01 to duration
        Duration: months=2
      Expression:
        Date Spec: months=7-8 weekdays=6-7 years=2019
      Expression: date in_range to 2019-12-15

[root@virt-134 ~]# pcs resource op defaults set create id=op_def score=10 meta timeout=5s rule \(defined attr1 or attr2 gte number 12 or attr3 lt version 3.2.1 or attr4 ne string test or attr5 lt 3\) and \(date gt 2018-05-17T13:28:19 or date in_range 2019-01-01 to 2019-03-15 or date in_range 2019-05-01 to duration months=2 or date-spec years=2019 months=7-8 weekdays=6-7 or date in_range to 2019-12-15\)
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource op defaults
Meta Attrs: op_defined score=10
  timeout=5s
  Rule: boolean-op=and score=INFINITY
    Expression: op monitor
    Expression: resource ocf:heartbeat:Dummy
    Expression: defined test_attr
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_def score=10
  timeout=5s
  Rule: boolean-op=and score=INFINITY
    Rule: boolean-op=or score=0
      Expression: defined attr1
      Expression: attr2 gte number 12
      Expression: attr3 lt version 3.2.1
      Expression: attr4 ne string test
      Expression: attr5 lt 3
    Rule: boolean-op=or score=0
      Expression: date gt 2018-05-17T13:28:19
      Expression: date in_range 2019-01-01 to 2019-03-15
      Expression: date in_range 2019-05-01 to duration
        Duration: months=2
      Expression:
        Date Spec: months=7-8 weekdays=6-7 years=2019
      Expression: date in_range to 2019-12-15

> OK


The verification will continue after resolving found issue with node attributes expressions (point 1 of the verification) in pacemaker - bz1891929. To allign with the pacemaker bz, which is now at ITM 15, switching this bz to ITM 15 as well.

Comment 13 Michal Mazourek 2021-02-11 10:00:45 UTC
After discussion, the issue described in comment 11 will not be resolved in pacemaker, but rather in pcs - bz1896458. Based on comment 11 and bz1896458 marking as VERIFIED for pcs-0.10.7-1.el8.

Comment 15 errata-xmlrpc 2021-05-18 15:12:08 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-2021:1737


Note You need to log in before you can comment on or make changes to this bug.