Bug 1390071

Summary: "pcs resource create" produces invalid cib on disallowed value of operation attribute
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, 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: Command "pcs resource create" does not validate attributes of operation correctly. Consequence: Pcs produces invalid cib and ends with an error message. From the error message it is difficult to identify the cause. Fix: Command "pcs resource create" validate attributes of operation correctly. Result: Pcs ends with an error message that is helpful for the user.
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-31 07:43:07 UTC
Description of problem:
When disallowed role of resource operation is entered in the "pcs resource create" command, pcs suggests to use flag --force. But the command with flag --force produces invalid cib.


Steps to Reproduce:

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor role=abc             
Error: role must be: Stopped, Started, Slave or Master (use --force to override)
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor role=abc --force


Actual results:
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor role=abc             
Error: role must be: Stopped, Started, Slave or Master (use --force to override)
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor role=abc --force
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib 

     
Expected results:
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor role=abc             
Error: role must be: Stopped, Started, Slave or Master
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor role=abc --force
Error: role must be: Stopped, Started, Slave or Master

Comment 1 Ivan Devat 2016-10-31 08:53:23 UTC
Note that there are more op-attributes that suffers with a similar problem:

> requires (should be one of: nothing quorum fencing unfencing)
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor requires=abc
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib....

> on-fail (should be one of: ignore block stop restart standby fence)
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor on-fail=abc
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib...

> record-pending (should be boolean true or false)
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor record-pending=abc
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib...

> enabled (should be boolean true or false)
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor enabled=abc
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib

Comment 2 Ivan Devat 2017-01-09 09:04:27 UTC
> start-delay and interval-origin can not appear together
[vm-rhel72-1 ~] $  pcs resource create R ocf:heartbeat:Dummy op monitor start-delay=10 interval-origin=20
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib...

Comment 4 Ivan Devat 2017-02-01 08:53:07 UTC
Created attachment 1246588 [details]
proposed fix

Tests are in the patch.

Comment 5 Ivan Devat 2017-02-20 08:14:14 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 role=abc
Error: 'abc' is not a valid role value, use Master, Slave, Started, Stopped

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor role=abc --force
Error: 'abc' is not a valid role value, use Master, Slave, Started, Stopped


[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor requires=abc
Error: 'abc' is not a valid requires value, use fencing, nothing, quorum, unfencing

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor requires=abc --force
Error: 'abc' is not a valid requires value, use fencing, nothing, quorum, unfencing


[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor on-fail=abc
Error: 'abc' is not a valid on-fail value, use block, fence, ignore, restart, restart-container, standby, stop

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor on-fail=abc --force
Error: 'abc' is not a valid on-fail value, use block, fence, ignore, restart, restart-container, standby, stop


[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor record-pending=abc
Error: 'abc' is not a valid record-pending value, use 0, 1, false, true

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor record-pending=abc --force
Error: 'abc' is not a valid record-pending value, use 0, 1, false, true


[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor enabled=abc
Error: 'abc' is not a valid enabled value, use 0, 1, false, true

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor enabled=abc --force
Error: 'abc' is not a valid enabled value, use 0, 1, false, true

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