Bug 1500012

Summary: provide a hint about the "set" option for cmds containing multiple "then" keywords in their constraint definitions
Product: Red Hat Enterprise Linux 7 Reporter: Corey Marthaler <cmarthal>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: medium    
Version: 7.4CC: aherr, cfeist, cluster-maint, idevat, mmazoure, nhostako, omular, tojeline
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: pcs-0.9.168-3.el7 Doc Type: Bug Fix
Doc Text:
Cause: The user specifies multiple resources in the 'pcs constraint colocation add' or 'pcs constraint order' commands. Consequence: A constraint for the first two resources is created, the other resources are silently ignored, no error is reported. Fix: Improve command line parsing and validation in the commands. Result: The user is informed that exactly two resources may be specified in the commands. They are advised to use set constraints instead to set constraints for multiple resources.
Story Points: ---
Clone Of:
: 1734361 (view as bug list) Environment:
Last Closed: 2020-03-31 19:09:37 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 Corey Marthaler 2017-10-09 16:00:29 UTC
Description of problem:
After further manual reading, I learned when defining order constraints for multiple resources at once, you need to use the "set" command. However, until I learned that, pcs was fine letting me think I had done everything correctly with multiple "then"'s in my cmd.

 
[root@host-081 ~]# pcs resource show
 Clone Set: dlm_for_lvmlockd-clone [dlm_for_lvmlockd]
     Started: [ host-081 host-094 host-095 ]
 Clone Set: lvmlockd-clone [lvmlockd]
     Started: [ host-081 host-094 host-095 ]
 Clone Set: QA-lvmlockd-activation-clone [QA-lvmlockd-activation]
     Started: [ host-081 host-094 host-095 ]

[root@host-081 ~]# pcs constraint order start dlm_for_lvmlockd-clone then start lvmlockd-clone then start QA-lvmlockd-activation-clone Serialize
Adding dlm_for_lvmlockd-clone lvmlockd-clone (kind: Mandatory) (Options: first-action=start then-action=start)

[root@host-081 ~]# pcs constraint show --full
Location Constraints:
Ordering Constraints:
  start dlm_for_lvmlockd-clone then start lvmlockd-clone (kind:Mandatory) (id:order-dlm_for_lvmlockd-clone-lvmlockd-clone-mandatory)
Colocation Constraints:
Ticket Constraints:

[root@host-081 ~]# pcs constraint  remove order-dlm_for_lvmlockd-clone-lvmlockd-clone-mandatory
[root@host-081 ~]# pcs constraint show --full
Location Constraints:
Ordering Constraints:
Colocation Constraints:
Ticket Constraints:

# This cmd resulted in the exact same thing as above since the final "then" is just getting dropped
[root@host-081 ~]# pcs constraint order start dlm_for_lvmlockd-clone then start lvmlockd-clone Serialize
Adding dlm_for_lvmlockd-clone lvmlockd-clone (kind: Mandatory) (Options: first-action=start then-action=start)
[root@host-081 ~]# pcs constraint show --full
Location Constraints:
Ordering Constraints:
  start dlm_for_lvmlockd-clone then start lvmlockd-clone (kind:Mandatory) (id:order-dlm_for_lvmlockd-clone-lvmlockd-clone-mandatory)
Colocation Constraints:
Ticket Constraints:

[root@host-081 ~]# pcs constraint  remove order-dlm_for_lvmlockd-clone-lvmlockd-clone-mandatory

# This should fail:
[root@host-081 ~]# pcs constraint order start dlm_for_lvmlockd-clone then start nonexistentresource-clone Serialize
Error: Resource 'nonexistentresource-clone' does not exist

# As should this I would think:
[root@host-081 ~]# pcs constraint order start dlm_for_lvmlockd-clone then start lvmlockd-clone then start nonexistentresource-clone Serialize
Adding dlm_for_lvmlockd-clone lvmlockd-clone (kind: Mandatory) (Options: first-action=start then-action=start)
[root@host-081 ~]# echo $?
0


# After further reading, I found that the "set" option is what I was looking for.
order set <resource1> [resourceN]

[root@host-081 ~]# pcs constraint order set dlm_for_lvmlockd-clone lvmlockd-clone nonexistentresource-clone
Error: resource 'nonexistentresource-clone' does not exist

[root@host-081 ~]# pcs constraint order set dlm_for_lvmlockd-clone lvmlockd-clone QA-lvmlockd-activation-clone sequential=true
[root@host-081 ~]# pcs constraint show --full
Location Constraints:
Ordering Constraints:
  Resource Sets:
    set dlm_for_lvmlockd-clone lvmlockd-clone QA-lvmlockd-activation-clone sequential=true (id:pcs_rsc_set_dlm_for_lvmlockd-clone_lvmlockd-clone_QA-lvmlockd-activation-clone) (id:pcs_rsc_order_set_dlm_for_lvmlockd-clone_lvmlockd-clone_QA-lvmlockd-activation-clone)
Colocation Constraints:
Ticket Constraints:


Version-Release number of selected component (if applicable):
pcs-0.9.158-6.el7.x86_64

Comment 3 Tomas Jelinek 2017-10-10 07:37:35 UTC
Order constraints cmdline parsing needs to be fixed to only accept a pair of resources. If more than two resources are specified, pcs should exit with an error. The error should, apart from telling the syntax is not valid, hint that a set constraint may be used instead.

The same should be done for colocation constraints.

Comment 5 Tomas Jelinek 2019-08-01 09:05:51 UTC
Created attachment 1596887 [details]
proposed fix + tests

In order to fix the reported issue properly a few more fixes had to be implemented:
* 'pcs constraint colocation add': report an error when multiple "with"s are specified, provide a hint that 'pcs constraint colocation set' should be used instead
* 'pcs constraint colocation add': report an error when specified resource roles are not valid
* 'pcs constraint colocation add': missing 'name' or '=value' in name=value options is reported as an error
* 'pcs constraint order': report an error when multiple "then"s are used, provide a hint that 'pcs constraint order set' should be used instead
* 'pcs constraint order': missing 'name' or '=value' in name=value options is reported as an error

Comment 6 Ivan Devat 2019-08-05 11:10:04 UTC
After Fix:

[kid76 ~] $ rpm -q pcs
pcs-0.9.168-1.el7.x86_64

[kid76 ~] $ pcs resource
 A      (ocf::heartbeat:Dummy): Started kid76
 B      (ocf::heartbeat:Dummy): Started lion76
 C      (ocf::heartbeat:Dummy): Started mule76

[kid76 ~] $ pcs constraint colocation add A with B with C

Usage: pcs constraint [constraints]...
    colocation add [master|slave] <source resource id> with [master|slave]
                   <target resource id> [score] [options] [id=constraint-id]
        Request <source resource> to run on the same node where pacemaker has
        determined <target resource> should run.  Positive values of score
        mean the resources should be run on the same node, negative values
        mean the resources should not be run on the same node.  Specifying
        'INFINITY' (or '-INFINITY') for the score forces <source resource> to
        run (or not run) with <target resource> (score defaults to "INFINITY").
        A role can be master or slave (if no role is specified, it defaults to
        'started').

Error: Multiple 'with's cannot be specified.
Hint: Use the 'pcs constraint colocation set' command if you want to create a constraint for more than two resources.


[kid76 ~] $ pcs constraint colocation add aster A with B
Error: invalid role value 'aster', allowed values are: 'Master', 'Slave', 'Started', 'Stopped'

[kid76 ~] $ pcs constraint colocation add A with B a=b name
Error: missing value of 'name' option

[kid76 ~] $ pcs constraint colocation add A with B "=value"
Error: missing key in '=value' option

[kid76 ~] $ pcs constraint order A then B then C

Usage: pcs constraint [constraints]...
    order [show] [--full]
        List all current ordering constraints (if --full is specified show
        the internal constraint id's as well).

    order [action] <resource id> then [action] <resource id> [options]
        Add an ordering constraint specifying actions (start, stop, promote,
        demote) and if no action is specified the default action will be
        start.
        Available options are kind=Optional/Mandatory/Serialize,
        symmetrical=true/false, require-all=true/false and id=<constraint-id>.

    order set <resource1> [resourceN]... [options] [set
              <resourceX> ... [options]]
              [setoptions [constraint_options]]
        Create an ordered set of resources.
        Available options are sequential=true/false, require-all=true/false and
        action=start/promote/demote/stop. Available constraint_options are
        id=<constraint-id>, kind=Optional/Mandatory/Serialize and
        symmetrical=true/false.

    order remove <resource1> [resourceN]...
        Remove resource from any ordering constraint

Error: Multiple 'then's cannot be specified.
Hint: Use the 'pcs constraint order set' command if you want to create a constraint for more than two resources.

[kid76 ~] $ pcs constraint order A then B "=value"
Error: missing key in '=value' option

[kid76 ~] $ pcs constraint order A then B a=b name
Error: missing value of 'name' option

Comment 15 Ivan Devat 2019-11-05 08:08:37 UTC
After Fix

[kid76 ~] $ rpm -q pcs
pcs-0.9.168-3.el7.x86_64

[kid76 ~] $ pcs constraint order A then B a=b name=
Error: value of 'name' option is empty

Comment 19 errata-xmlrpc 2020-03-31 19:09:37 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-2020:0996