Bug 1222691

Summary: "rule date in_range to <date>" should be valid syntax
Product: Red Hat Enterprise Linux 8 Reporter: Jan Pokorný [poki] <jpokorny>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact: Steven J. Levine <slevine>
Priority: low    
Version: 8.0CC: cfeist, cluster-maint, idevat, mlisik, mmazoure, mpospisi, nhostako, omular, slevine, tojeline
Target Milestone: rc   
Target Release: 8.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.10.7-1.el8 Doc Type: Enhancement
Doc Text:
Feature: Support 'date in_range [<date>] to <date>' syntax in rules, previously only 'date in_range <date> to <date>' was supported. Reason: Pacemaker allows to omit the start date in in_range expressions. Result: The start date in in_range expression can be omitted. Note this is not supported in location constraint rules.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:12:05 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 Jan Pokorný [poki] 2015-05-18 20:26:58 UTC
... as "start" parameter (attribute in pacemaker-1.2.rng) should be
optional.

As for the help screen:

> Usage: pcs constraint [constraints]...
> Manage resource constraints
> 
> Commands:
> [...]
>     location <resource id> rule [id=<rule id>] [role=master|slave]
>              [constraint-id=<id>] [score=<score>|score-attribute=<attribute>]
>              <expression>
>         Creates a location rule on the specified resource where the expression
>         looks like one of the following:
> [...]
>           date in_range <date> to <date>

^ last line in this excerpt should read:
>           date in_range [<date> to] <date>

Comment 1 Jan Pokorný [poki] 2015-05-18 20:41:46 UTC
Currently, one obtains:

# pcs constraint location RESID rule date in_range to 2016-01-01
> Error: 'date in_range to 2016-01-01' is not a valid rule expression:
>         unexpected 'to'

Comment 2 Jan Pokorný [poki] 2015-05-18 20:42:49 UTC
re [comment 0]:

Actually, the last line in the excerpt should read:
>           date in_range [<date>] to <date>

Comment 5 Tomas Jelinek 2020-09-18 13:53:35 UTC
Created attachment 1715374 [details]
proposed fix + tests

Syntax before fix:
date in_range <date> to <date>
Syntax after fix:
date in_range [<date>] to <date>

This fix only applies to resource and operation defaults. It doesn't apply to location constraints as those haven't been moved to the new pcs architecture yet and fixing relevant legacy code is not feasible. Once location constraints code is overhauled and moved to the new pcs architecture, it will support the new syntax as well.

Test:
pcs resource defaults set create rule date in_range to 2021-01-01
pcs resource op defaults set create rule date in_range to 2021-01-01

Comment 13 Miroslav Lisik 2020-10-14 13:48:43 UTC
Test:

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

[root@r8-node-01 ~]# pcs resource defaults
No defaults set
[root@r8-node-01 ~]# pcs resource op defaults
No defaults set
[root@r8-node-01 ~]# pcs resource defaults set create rule date in_range to 2021-01-01
Warning: Defaults do not apply to resources which override them with their own defined values
[root@r8-node-01 ~]# pcs resource op defaults set create rule date in_range to 2021-01-01
Warning: Defaults do not apply to resources which override them with their own defined values
[root@r8-node-01 ~]# pcs resource defaults
Meta Attrs: rsc_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: date in_range to 2021-01-01
[root@r8-node-01 ~]# pcs resource op defaults
Meta Attrs: op_defaults-meta_attributes
  Rule: boolean-op=and score=INFINITY
    Expression: date in_range to 2021-01-01

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