Bug 1362493

Summary: pcs does not support rsc-pattern in location constraints
Product: Red Hat Enterprise Linux 7 Reporter: Tomas Jelinek <tojeline>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact: Steven J. Levine <slevine>
Priority: high    
Version: 7.3CC: cfeist, cluster-maint, fdinitto, idevat, jpokorny, omular, royoung, rsteiger, tojeline
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.157-1.el7 Doc Type: Release Note
Doc Text:
Support for regular expressions in `pcs` command line when configuring location constraints `pcs` now supports regular expressions in location constraints on the command line. These constraints apply to multiple resources based on the regular expression matching resource name. This simplifies cluster management as one constraint may be used where several were needed before.
Story Points: ---
Clone Of:
: 1424387 (view as bug list) Environment:
Last Closed: 2017-08-01 18:22:57 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:
Bug Depends On:    
Bug Blocks: 1424387    
Attachments:
Description Flags
proposed fix none

Description Tomas Jelinek 2016-08-02 11:11:43 UTC
<rsc_location id="location-haproxy-ips" resource-discovery="exclusive" rsc-pattern="^(ip-.*)">
<rsc_location id="location-nova-compute-clone" resource-discovery="exclusive" rsc-pattern="nova-compute-(.*)">

It has been kicking around for a while but mostly in the experimental part of the schema. Now it is in upstream master. Still have to document it, but it is
fairly self-explanatory. Expected in rhel 7.4.

Comment 1 Tomas Jelinek 2016-08-02 15:13:21 UTC
"rsc-pattern" is supported since validate-with=pacemaker-2.6

Comment 3 Tomas Jelinek 2017-02-17 16:49:19 UTC
Created attachment 1254330 [details]
proposed fix

Tests are included in the patch.

Comment 4 Ivan Devat 2017-04-10 15:48:17 UTC
After Fix:

[vm-rhel72-1 ~] $ rpm -q pcs
pcs-0.9.157-1.el7.x86_64

Setup:
pcs resource create R ocf:heartbeat:Dummy

1)
[vm-rhel72-1 ~] $ pcs constraint location %R prefers vm-rhel72-1
[vm-rhel72-1 ~] $ pcs cluster cib|grep "rsc_location" -B1 -A1
    <constraints>
      <rsc_location id="location-R-vm-rhel72-1-INFINITY" node="vm-rhel72-1" rsc="R" score="INFINITY"/>
    </constraints>
[vm-rhel72-1 ~] $ pcs constraint remove location-R-vm-rhel72-1-INFINITY

2)
[vm-rhel72-1 ~] $ pcs constraint location resource%R prefers vm-rhel72-1
[vm-rhel72-1 ~] $ pcs cluster cib|grep "rsc_location" -B1 -A1
    <constraints>
      <rsc_location id="location-R-vm-rhel72-1-INFINITY" node="vm-rhel72-1" rsc="R" score="INFINITY"/>
    </constraints>
[vm-rhel72-1 ~] $ pcs constraint remove location-R-vm-rhel72-1-INFINITY

3)
[vm-rhel72-1 ~] $ pcs constraint location regexp%res_[0-9] prefers node1
[vm-rhel72-1 ~] $ pcs cluster cib|grep "rsc_location" -B1 -A1
    <constraints>
      <rsc_location id="location-res_0-9-node1-INFINITY" node="node1" rsc-pattern="res_[0-9]" score="INFINITY"/>
    </constraints>
[vm-rhel72-1 ~] $ pcs constraint remove location-res_0-9-node1-INFINITY

4)
[vm-rhel72-1 ~] $ pcs constraint location "regexp%res_[0-9]" avoids node1
[vm-rhel72-1 ~] $ pcs cluster cib|grep "rsc_location" -B1 -A1
    <constraints>
      <rsc_location id="location-res_0-9-node1--INFINITY" node="node1" rsc-pattern="res_[0-9]" score="-INFINITY"/>
    </constraints>
[vm-rhel72-1 ~] $ pcs constraint remove location-res_0-9-node1--INFINITY

5)
[vm-rhel72-1 ~] $ pcs constraint location add my-id "regexp%res_[0-9]" node1 INFINITY
[vm-rhel72-1 ~] $ pcs cluster cib|grep "rsc_location" -B1 -A1
    <constraints>
      <rsc_location id="my-id" node="node1" rsc-pattern="res_[0-9]" score="INFINITY"/>
    </constraints>
[vm-rhel72-1 ~] $ pcs constraint remove my-id

6)
[vm-rhel72-1 ~] $ pcs constraint location "regexp%res_[0-9]"  rule '#uname' eq node1
[vm-rhel72-1 ~] $ pcs cluster cib|grep "<rsc_location" -B1 -A5
    <constraints>
      <rsc_location id="location-res_0-9" rsc-pattern="res_[0-9]">
        <rule id="location-res_0-9-rule" score="INFINITY">
          <expression attribute="#uname" id="location-res_0-9-rule-expr" operation="eq" value="node1"/>
        </rule>
      </rsc_location>
    </constraints>
[vm-rhel72-1 ~] $ pcs constraint remove location-res_0-9

Comment 10 errata-xmlrpc 2017-08-01 18:22:57 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, 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/RHBA-2017:1958