Bug 1673835

Summary: 'pcs constraint location <rsc> prefers|avoids' should not create any constraint unless the whole command is valid
Product: Red Hat Enterprise Linux 8 Reporter: Tomas Jelinek <tojeline>
Component: pcsAssignee: Michal Pospisil <mpospisi>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 8.0CC: cfeist, cluster-maint, idevat, mlisik, mmazoure, omular, tojeline
Target Milestone: rc   
Target Release: 8.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.10.3-1.el8 Doc Type: Bug Fix
Doc Text:
Cause: user configures location constraints with pcs location constraint prefers/avoids and enters invalid node name or score for other than the first node Consequence: command fails but location constraint had been created for all nodes that had valid node names and scores positioned before the invalid name/score in the command Fix: before creating any location constraints, node names and scores are checked Result: no location constraints are created unless all node names and scores are valid
Story Points: ---
Clone Of: 1525381 Environment:
Last Closed: 2020-04-28 15:27:56 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: 1682129    
Bug Blocks:    

Description Tomas Jelinek 2019-02-08 09:24:13 UTC
+++ This bug was initially created as a clone of Bug #1525381 +++

Description of problem:
'pcs constraint location <rsc> prefers|avoids' should not create any constraint unless the whole command is valid


Version-Release number of selected component (if applicable):
pcs-0.9.162-1.el7


How reproducible:
always, easily


Steps to Reproduce:
[root@rh74-node1:~]# pcs constraint
Location Constraints:
Ordering Constraints:
Colocation Constraints:
Ticket Constraints:

[root@rh74-node1:~]# pcs constraint location dummy avoids node1 resource-discovery=never
Error: invalid score 'never', use integer or INFINITY or -INFINITY

[root@rh74-node1:~]# echo $?
1

[root@rh74-node1:~]# pcs constraint
Location Constraints:
  Resource: dummy
    Disabled on: node1 (score:-INFINITY)
Ordering Constraints:
Colocation Constraints:
Ticket Constraints:


Actual results:
A constraint is created. An error is reported and pcs returns 1.


Expected results:
No constraint is created. An error is reported and pcs returns 1.

Comment 3 Michal Pospisil 2019-09-06 08:35:17 UTC
Fix merged into upstream master: https://github.com/ClusterLabs/pcs/commit/095113b23216cfb65fdd863d3955566ebb64a79c

ENVIRONMENT PREPARATION:
- a 2 node cluster with nodes: node1, node2
- a dummy resource (pcs resource create dummy ocf:heartbeat:Dummy)

To test this fix, run commands:
# pcs constraint location dummy prefers node1 node2=invalid
# echo $?
1
# pcs constraint location show 
Location Constraints:

# pcs constraint location dummy avoids node1=-50 node2
# echo $?
0
# pcs constraint location show 
Location Constraints:
  Resource: dummy
    Enabled on: node1 (score:50)
    Disabled on: node2 (score:-INFINITY)

Comment 4 Miroslav Lisik 2019-10-23 15:24:54 UTC
After fix:

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

[root@r81-node-01 pcs]# pcs constraint location d-01 prefers r81-node-01 r81-node-02=invalid
Error: invalid score 'invalid', use integer or INFINITY or -INFINITY
[root@r81-node-01 pcs]# echo $?
1
[root@r81-node-01 pcs]# pcs constraint location d-01 avoids r81-node-01=-50 r81-node-02
[root@r81-node-01 pcs]# echo $?
0
[root@r81-node-01 pcs]# pcs constraint
Location Constraints:
  Resource: d-01
    Enabled on:
      Node: r81-node-01 (score:50)
    Disabled on:
      Node: r81-node-02 (score:-INFINITY)
Ordering Constraints:
Colocation Constraints:
Ticket Constraints:

Comment 8 errata-xmlrpc 2020-04-28 15:27:56 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/RHEA-2020:1568