Bug 1382597

Summary: "pcs resource create" produces invalid cib when the use of unknown op attribute is forced
Product: Red Hat Enterprise Linux 7 Reporter: Ivan Devat <idevat>
Component: pcsAssignee: Ivan Devat <idevat>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 7.2CC: cfeist, cluster-maint, idevat, jpokorny, omular, rsteiger, tojeline
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.156-1.el7 Doc Type: Bug Fix
Doc Text:
Cause: Pcs allows the user to enforce invalid attribute of resource operation in "pcs resource create". Consequence: Pcs produces invalid cib ends with an error message. From the error message it is difficult to identify the cause. Fix: Pcs does not allow the user to enforce invalid attribute of resource operation in "pcs resource create". Result: It is not possible to enforce invalid attribute of resource operation in "pcs resource create".
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 18:24:40 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 none

Description Ivan Devat 2016-10-07 06:49:38 UTC
Description of problem:
When unknown op-attribute is entered in the "pcs resource create", pcs suggests to use flag --force.
But the command with flag --force produces invalid cib.

How reproducible: always


Steps to Reproduce:
1.
[vm-rhel72-1 ~] $ pcs resource create dummy Dummy op monitor interval=1min a=b
Error: a is not a valid op option (use --force to override)
2.
[vm-rhel72-1 ~] $ pcs resource create dummy Dummy op monitor interval=1min a=b --force


Actual results:
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib...
[vm-rhel72-1 ~] $ echo $?
1


Expected results:
[vm-rhel72-1 ~] $ echo $?
0
[vm-rhel72-1 ~] $ pcs resource show dummy
 Resource: dummy (class=ocf provider=heartbeat type=Dummy)
  Operations: start interval=0s timeout=20 (dummy-start-interval-0s)
              stop interval=0s timeout=20 (dummy-stop-interval-0s)
              monitor interval=1min a=b (dummy-monitor-interval-1min)


Additional info:
The problem is that pcs put the attribute "a" to the "op" element as attribute. And it does not conform schema. Pcs could put the attribute "a" as instance attribute (in nvpair) of "op" element:

<op id="dummy-monitor-interval-1min" interval="1min" name="monitor">
  <instance_attributes id="params-dummy-monitor-interval-1min">
    <nvpair id="dummy-monitor-interval-1min-a" name="a" value="b"/>
  </instance_attributes>
</op>

Comment 1 Ivan Devat 2017-01-09 08:55:07 UTC
Putting invalid attributes into "instance_attributes" of "op" is not a good idea. Currently there is no syntax to distinguish between attributes of "op" and "instance_attributes" of "op".

Currently in "pcs resource create" it is not possible to specify "instance_attributes" of "op". The only exception is OCF_CHECK_LEVEL (alias "depth") which is always put in "instance_attributes" of "op".

Because of this we are not going to allow to specify "instance_attributes" of "op" for now.

Comment 3 Ivan Devat 2017-01-31 16:54:01 UTC
Created attachment 1246366 [details]
proposed fix

Tests are in the patch.

Comment 4 Ivan Devat 2017-02-20 08:08:54 UTC
After Fix:

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

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor interval=1min a=b
Error: invalid resource operation option 'a', allowed options are: OCF_CHECK_LEVEL, description, enabled, id, interval, interval-origin, name, on-fail, record-pending, requires, role, start-delay, timeout

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor interval=1min a=b --force
Error: invalid resource operation option 'a', allowed options are: OCF_CHECK_LEVEL, description, enabled, id, interval, interval-origin, name, on-fail, record-pending, requires, role, start-delay, timeout

Comment 8 Jan Pokorný [poki] 2017-07-11 21:11:03 UTC
re [comment ]:

> Putting invalid attributes into "instance_attributes" of "op" is not
> a good idea. Currently there is no syntax to distinguish between
> attributes of "op" and "instance_attributes" of "op".

Probably should have been discussed in wider circles :-/

See [bug 1469801].

Comment 9 errata-xmlrpc 2017-08-01 18:24:40 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