RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1891929 - [RFE] Default rules with node attributes expressions can be created but are not in effect
Summary: [RFE] Default rules with node attributes expressions can be created but are n...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: pacemaker
Version: 8.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.4
Assignee: Chris Lumens
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-10-27 17:18 UTC by Michal Mazourek
Modified: 2020-12-08 13:15 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-06 22:24:49 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Michal Mazourek 2020-10-27 17:18:35 UTC
Description of problem:
Found while testing bz1862966.
Default rule that contains node attribute in expression can be created, but doesn't seem to be in an actual effect.
The functionality check of this was based on resource-stickiness, where the resource, on which is the default rule applied, shouldn't move from a node after other resource is moved there. 
Default rules with dates and resources in expressions work fine, the only issue is with node attributes.


Version-Release number of selected component (if applicable):
pacemaker-2.0.5-1.el8.x86_64 (probably will be in 8.3 as well)
pcs-0.10.7-1.el8.x86_64


How reproducible:
always


Steps to Reproduce: 2-node cluster
1. create node attributes
[root@virt-134 ~]# pcs node attribute virt-134 test_attr=5
[root@virt-134 ~]# pcs node attribute virt-135 test_attr=10
[root@virt-134 ~]# pcs node attribute
Node Attributes:
 virt-134: test_attr=5
 virt-135: test_attr=10

2. create default rule with the node attribute in its expression
[root@virt-134 ~]# pcs resource defaults set create id=res_defined score=10 meta resource-stickiness=100 rule resource ocf:heartbeat:Dummy and defined test_attr
Warning: Defaults do not apply to resources which override them with their own defined values
[root@virt-134 ~]# pcs resource defaults
Meta Attrs: res_defined score=10
  resource-stickiness=100
  Rule: boolean-op=and score=INFINITY
    Expression: resource ocf:heartbeat:Dummy
    Expression: defined test_attr

> this rule should apply resource-stickness 100 on ocf:heartbeat:Dummy resources, when node attribute 'test_attr' is defined.

3. test, that the rule will really apply on the created ocf:heartbeat:Dummy resource by functionality check described above.
+ pcs resource create d1 ocf:pacemaker:Dummy
+ pcs resource create d2 ocf:heartbeat:Dummy
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-134
  * d2	(ocf::heartbeat:Dummy):	 Started virt-135
+ pcs resource move d1 virt-135
+ pcs resource
  * Clone Set: locking-clone [locking]:
    * Started: [ virt-134 virt-135 ]
  * d1	(ocf::pacemaker:Dummy):	 Started virt-135
  * d2	(ocf::heartbeat:Dummy):	 Started virt-134


Actual results:
The rule didn't apply on ocf:heartbeat:Dummy (d2), as it moved away from virt-135 after resource d1 was moved there. It indicates, that the expression was evaluated as false, even though test_attr node attribute was defined and ocf:heartbeat:Dummy was used. 
The same result is happening with other node attributes expressions as well, like 'not_defined <node attribute>' and '<node attribute> lt|gt|lte|gte|eq|ne [string|integer|number|version] <value>'.


Expected results:
The rule will apply on ocf:heartbeat:Dummy (d2), which will not move away from virt-135 after d1 is moved there. This result has been achieved with all other expression types (e.g. dates).


Additional info:
After discussion with pcs devel, this bz is created under pacemaker component. Original pacemaker bz for this feature is from 8.3 - bz1628701.

Comment 1 Ken Gaillot 2020-11-02 17:35:34 UTC
Thanks for the report. A few issues are entangled here:

* Rules may be used in multiple contexts (cluster options, resource defaults, location constraints, etc.). Certain rule configuration elements are only used in certain contexts, but Pacemaker's CIB schema does not prevent users from configuring those in other contexts, where they will be ignored or always make the rule evaluation false.

* Upstream documentation is silent on whether node attribute expressions are allowed in resource defaults. It does mention that they are allowed in an individual resource's configuration, and that they are disallowed in cluster-wide options. I don't think we have much downstream documentation on the subject, but instead rely on pcs's man page.

* Node attribute expressions are currently always treated as false in resource defaults, but pcs allows it, and there's a reasonable argument Pacemaker should support them. I would consider this an RFE.

The fix for the first issue is straightforward, but unfortunately we can't do it right now because it could potentially invalidate existing configurations that currently work fine. The ideal time to do it would be the next time upstream does a major-version schema update in Pacemaker, which would include an XSL transform to drop unsupported rules from existing configurations. That will likely be in the RHEL 10 time frame. In the meantime, we could add a configuration warning when a rule is used in an unsupported context.

The second issue is also straightforward, and we can take care of it once we decide what to do about the third issue. My first thought is that it should be reasonably simple to implement, but there may be some reason I'm overlooking why it was never hooked up to begin with.

To sum up, for this BZ, we can:
1. Update the upstream documentation to clearly indicate where each element of rule syntax can be used.
2. Start logging a configuration warning when rule elements are used in unsupported contexts.
3. Investigate whether supporting node attribute expressions in resource defaults is feasible.

Comment 2 Tomas Jelinek 2020-11-03 08:20:34 UTC
(In reply to Ken Gaillot from comment #1)
> * Node attribute expressions are currently always treated as false in
> resource defaults, but pcs allows it, and there's a reasonable argument
> Pacemaker should support them. I would consider this an RFE.

Well, sorry about that. :) I was working with Ken's comment in bz1869399 comment0, "Also, the help for "pcs resource op defaults set create" and "pcs resource defaults set create" implies that only resource and operation expressions are allowed there. Date/time expressions and node attribute expressions are also allowed.". Based on that, it was my impression node attribute expressions are actually supported by Pacemaker. That's why I went ahead and added support for them in pcs.

If node attribute expressions are not going to be supported by pacemaker, feel free to move this bz to pcs. We can modify rule validators in pcs so that they prevent node attribute expressions being used.

Comment 3 Ken Gaillot 2020-11-03 16:57:53 UTC
(In reply to Tomas Jelinek from comment #2)
> (In reply to Ken Gaillot from comment #1)
> > * Node attribute expressions are currently always treated as false in
> > resource defaults, but pcs allows it, and there's a reasonable argument
> > Pacemaker should support them. I would consider this an RFE.
> 
> Well, sorry about that. :) I was working with Ken's comment in bz1869399

Don't listen to that guy, he doesn't know what he's talking about :-P

> comment0, "Also, the help for "pcs resource op defaults set create" and "pcs
> resource defaults set create" implies that only resource and operation
> expressions are allowed there. Date/time expressions and node attribute
> expressions are also allowed.". Based on that, it was my impression node

Technically node attribute expressions are allowed, they're just always false ;-)

Obviously it's easy to think they would be supported, even having some familiarity with the code, so I'm leaning to adding the support in Pacemaker if there's not some large design roadblock. Since there's no documentation, I'll still consider it an RFE.

> attribute expressions are actually supported by Pacemaker. That's why I went
> ahead and added support for them in pcs.
> 
> If node attribute expressions are not going to be supported by pacemaker,
> feel free to move this bz to pcs. We can modify rule validators in pcs so
> that they prevent node attribute expressions being used.

I'll target 8.5 for the pacemaker feature since QA is at capacity for 8.4. If QA winds up having more time near the end, we might be able to get this in for 8.4. It's up to you what to do about pcs in 8.4.

Comment 4 Ken Gaillot 2020-11-04 18:14:18 UTC
After further discussion, we've decided that this bz should focus on the narrow issue of node attribute expressions being allowed in resource defaults. We have a good chance of getting that in 8.4.

Comment 6 Chris Lumens 2020-11-04 21:49:15 UTC
Could you attach the CIB after adding the resources in step #3, but before moving the one resource?  I'd like to verify that I am writing a test case for the correct thing here.  Thanks.

Comment 8 Ken Gaillot 2020-11-06 22:24:49 UTC
After further investigation, we determined that it is correct but undocumented behavior that node attribute expressions are not supported for *meta-attributes*, except in the context of an operation or operation defaults. Node attribute expressions do not work with meta-attributes in a resource's configuration, resource defaults, or cluster properties.

Node attribute expressions should work for resource options (instance attributes), whether in the resource configuration or resource defaults, so it is correct that pcs allows node attribute expressions in resource defaults. (That can be used in testing the original bz.) It would probably be a good idea for pcs to reject the combination of meta and node attribute rules for resource defaults.

This makes sense when you consider that only an operation is directly associated with a single node. Most meta-attributes would make no sense being node-specific (target-role, allow-migrate, etc.). While some might (resource-stickiness, migration-threshold), that would be an unusual use case, and I'd rather wait until there is customer demand before formalizing that as an RFE.

I'm not sure whether this needs to be documented in RHEL. I believe rules are currently documented only in the context of location constraints (https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_high_availability_clusters/assembly_determining-resource-location-with-rules-configuring-and-managing-high-availability-clusters) so there's no existing place for it. Possibly the pcs man page could be updated for "pcs resource defaults".

Pacemaker should enforce proper rule syntax usage more strictly via its XML schema, but for compatibility reasons that is not feasible in the RHEL 8 time frame.


Note You need to log in before you can comment on or make changes to this bug.