Bug 2166294

Summary: [cli] "constraint location show nodes" displays empty entries for rule constraints
Product: Red Hat Enterprise Linux 8 Reporter: Tomas Jelinek <tojeline>
Component: pcsAssignee: Ondrej Mular <omular>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: low    
Version: 8.0CC: cfeist, cluster-maint, idevat, mlisik, mpospisi, nhostako, omular, slevine, tojeline
Target Milestone: rcKeywords: Triaged
Target Release: 8.9   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.10.16-1.el8 Doc Type: Bug Fix
Doc Text:
.Location constraints with rules no longer displayed when listing is grouped by nodes Location constraints with rules cannot have a node assigned. Previously, when you grouped the listing by nodes, location constraints with rules were displayed under an empty node. With this fix, the location constraints with rules are no longer displayed and a warning is given indicating that constraints with rules are not displayed.
Story Points: ---
Clone Of: 1423473 Environment:
Last Closed: 2023-11-14 15:22:35 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: 1423473    
Bug Blocks: 2163953, 2166291    

Description Tomas Jelinek 2023-02-01 12:57:27 UTC
+++ This bug was initially created as a clone of Bug #1423473 +++

Description of problem:
The "pcs constraint location show nodes" lists location constraints grouped by nodes. This works well for simple constraints, where a resource is assigned to a node with some score. However for rule constraints it display empty entries as there is no node defined in the constraint (that's what the rule is for).


Version-Release number of selected component (if applicable):
pcs-0.9.152-10.el7


How reproducible:
always, easily


Steps to Reproduce:
1. create a rule location constraint, for example # pcs constraint location d1 rule date-spec operation=date_spec years=2005
2. # pcs constraint location show nodes


Actual results:
Note: a simple constraint was created for comparison:
# pcs constraint location d1 prefers rh73-node1

# pcs constraint location show nodes
Location Constraints:
  Node: rh73-node1
    Allowed to run:
      d1 (location-d1-rh73-node1-INFINITY) Score: INFINITY
  Node: 
    Allowed to run:
      d1 (location-d1) Score: 0
  Resource: d1
    Constraint: location-d1
      Rule: score=-INFINITY
        Expression:
          Date Spec: years=2005

The "Node: rh73-node1" lines are for the simple constraint - those are correct and show what resources are constrained to that node.
The "Node:" lines belong to the rule constraint and they do not make much sense.


Expected results:
Not displaying rule constraints by node, i.e. remove the "Node: section with empty nodes.

--- Additional comment from Tomas Jelinek on 2017-02-17 14:05:07 CET ---

Also when displaying constraints for a specified nodes the output contains rule constraints. Those should not be displayed at all as they do not match the filter.

Comment 1 Ondrej Mular 2023-04-06 07:52:25 UTC
Upstream patch:
https://github.com/ClusterLabs/pcs/commit/270eb2a4846f898b7e5441357df59e1574f6d3cc

Location constraints with rules are not displayed when showing location constraints grouped by nodes.
See test:
https://github.com/ClusterLabs/pcs/commit/270eb2a4846f898b7e5441357df59e1574f6d3cc#diff-3510ab220f26c4e1c804d488c38c585b0862719eeb8e6c3235852dc1c9751794

Comment 2 Michal Pospisil 2023-05-29 10:10:00 UTC
DevTestResults:

(pcs) [root@r08-09-a pcs]# pcs_test/suite --installed --traditional-verbose pcs_test/tier1/legacy/test_constraints.LocationShowWithPattern.test_show
pcs_test.tier1.legacy.test_constraints.LocationShowWithPattern.test_show (subunit.RemotedTestCase)
pcs_test.tier1.legacy.test_constraints.LocationShowWithPattern.test_show ... OK

----------------------------------------------------------------------
Ran 1 test in 23.026s

OK

Comment 6 svalasti 2023-06-20 11:57:08 UTC
## BEFORE

[root@virt-482 ~]# rpm -q pcs
pcs-0.10.15-4.el8.x86_64

[root@virt-482 ~]# pcs resource create dummy ocf:heartbeat:Dummy

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

[root@virt-482 ~]# pcs resource
  * dummy	(ocf::heartbeat:Dummy):	 Started virt-482

[root@virt-482 ~]# pcs constraint location dummy prefers virt-484

[root@virt-482 ~]# pcs resource
  * dummy	(ocf::heartbeat:Dummy):	 Started virt-484

[root@virt-482 ~]# pcs constraint location dummy rule date-spec years=2023

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

[root@virt-482 ~]# pcs constraint location config nodes
Location Constraints:
  Node: 
    Allowed to run:
      Resource: dummy (score:0)
  Node: virt-484
    Allowed to run:
      Resource: dummy (score:INFINITY)
  Resource: dummy
    Constraint: location-dummy
      Rule: score=INFINITY
        Expression:
          Date Spec: years=2023

> The output of this command contained 'Node' section belonging to the location rule constraint, while its content did not make much sense.

## AFTER

[root@virt-539 ~]# rpm -q pcs
pcs-0.10.16-1.el8.x86_64

[root@virt-539 ~]# pcs resource create dummy ocf:heartbeat:Dummy

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

[root@virt-539 ~]# pcs resource
  * dummy	(ocf::heartbeat:Dummy):	 Started virt-539

[root@virt-539 ~]# pcs constraint location dummy prefers virt-540

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

[root@virt-539 ~]# pcs resource
  * dummy	(ocf::heartbeat:Dummy):	 Started virt-540


A.) Create a location constraint with a rule on the dummy resource (only date-spec is specified).

[root@virt-539 ~]# pcs constraint location dummy rule date-spec years=2023

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

[root@virt-539 ~]# pcs constraint location config nodes
Location Constraints:
  Node: virt-540
    Allowed to run:
      Resource: dummy (score:INFINITY)
  Resource: dummy
    Constraint: location-dummy
      Rule: score=INFINITY
        Expression:
          Date Spec: years=2023

> OK. In this case, the output of 'pcs constraint location config nodes' command does not contain the 'Node' section. 


B.) Create a location constraint with a rule on resource (+score property, + #uname node attribute in expression)

[root@virt-539 ~]# pcs resource create dummy2 ocf:heartbeat:Dummy

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

[root@virt-539 ~]# pcs constraint location dummy2 prefers virt-539

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

[root@virt-539 ~]# pcs constraint location dummy2 rule score=INFINITY "#uname" eq virt-539

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

[root@virt-539 ~]# pcs constraint location config nodes
Location Constraints:
  Node: virt-539
    Allowed to run:
      Resource: dummy2 (score:INFINITY)
  Resource: dummy2
    Constraint: location-dummy2
      Rule: score=INFINITY
        Expression: #uname eq virt-539

> OK. Also in this case, the output of 'pcs constraint location config nodes' command does not contain the 'Node' section. 

> Marking as VERIFIED for pcs-0.10.16-1.el8.x86_64

Comment 11 errata-xmlrpc 2023-11-14 15:22:35 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/RHBA-2023:6903