Bug 1389453

Summary: pcs operates incorrectly with "depth" attribute of resource operation
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, oalbrigt, 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: The user runs "pcs resource create" with a resource agent, that contains an action with attribute depth != 0. Consequence: Pcs produces invalid cib and ends with an error message. Fix: Pcs transforms attribute "depth" into instance attribute "OCF_CHECK_LEVEL". Result: Pcs creates correctly the resource with a resource agent that contains an action with attribute depth != 0.
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:
Attachments:
Description Flags
proposed fix none

Description Ivan Devat 2016-10-27 15:28:07 UTC
Description of problem:

Let us have a resource agent containing an action with the attribute "depth" != 0. Command "pcs resource create" produces invalid cib when such agent is used.

Steps to Reproduce:
> Prepare resource the agent containing an action with the attribute "depth" != 0.
  For example edit /usr/lib/ocf/resource.d/heartbeat/Dummy:
  Put line
    <action name="monitor"      timeout="20" interval="10" depth="0" />
  after line
    <action name="monitor"      timeout="20" interval="15" depth="10" />
  in metadata section.

> Try create resource with this agent
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy


Actual results:
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib ...
      <primitive class="ocf" id="R" provider="heartbeat" type="Dummy">
        <instance_attributes id="R-instance_attributes"/>
        <operations>
          <op id="R-start-interval-0s" interval="0s" name="start" timeout="20"/>
          <op id="R-stop-interval-0s" interval="0s" name="stop" timeout="20"/>
          <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20"/>
          <op depth="10" id="R-monitor-interval-15" interval="15" name="monitor" timeout="20"/>
        </operations>
      </primitive>
...

Expected results:
Success with cib including something like this:
      <primitive class="ocf" id="R" provider="heartbeat" type="Dummy">
        <instance_attributes id="R-instance_attributes"/>
        <operations>
          <op id="R-start-interval-0s" interval="0s" name="start" timeout="20"/>
          <op id="R-stop-interval-0s" interval="0s" name="stop" timeout="20"/>
          <op id="R-monitor-interval-10" interval="10" name="monitor"/>
          <op id="R-monitor-interval-15" interval="15" name="monitor">
            <instance_attributes id="params-R-monitor-interval-15">
              <nvpair id="R-monitor-interval-15-OCF_CHECK_LEVEL-10" name="OCF_CHECK_LEVEL" value="10"/>
            </instance_attributes>
          </op>
        </operations>
      </primitive>

Additional info:
> Different behavior in current upstream version.
In the current upstream version this problem is partially corrected - pcs does not produce invalid cib. However the attribute "depth" is ommitted. So in cib there is:
...
      <primitive class="ocf" id="R" provider="heartbeat" type="Dummy">
        <instance_attributes id="R-instance_attributes"/>
        <operations>
          <op id="R-start-interval-0s" interval="0s" name="start" timeout="20"/>
          <op id="R-stop-interval-0s" interval="0s" name="stop" timeout="20"/>
          <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20"/>
          <op id="R-monitor-interval-15" interval="15" name="monitor" timeout="20"/>
        </operations>
      </primitive>
...

> There is not possible use attribute "depth" in "pcs resource create" command:
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor depth=1
Error: depth is not a valid op option (use --force to override)
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy op monitor depth=1 --force
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib...

Similar behavior is described in rhbz#1382597. However attribute "depth" should take an extra care. Its use should result to operation instance attribute OCF_CHECK_LEVEL (see above).

Comment 1 Tomas Jelinek 2016-10-27 15:30:39 UTC
If we allow the "depth" attribute to be used, we need to handle a situation where both "depth" and "OCF_CHECK_LEVEL" is specified.

Comment 3 Ivan Devat 2017-02-01 07:44:13 UTC
Created attachment 1246568 [details]
proposed fix

Test:
> attribute "depth" in the resource agent is transformed into "OCF_CHECK_LEVEL"
1) Put the attribute "depth" != 0 into a resource agent
  Edit /usr/lib/ocf/resource.d/heartbeat/Dummy:
  Put line
    <action name="monitor"      timeout="20" interval="15" depth="10" />
  after line
    <action name="monitor"      timeout="20" interval="10" depth="0" />
  in metadata section.

2) Try to create a resource with this agent
[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy
Warning: changing a monitor operation interval from 10 to 11 to make the operation unique
[vm-rhel72-1 ~] $ pcs cluster cib scope=resources | grep 'id="R"' -A11
  <primitive class="ocf" id="R" provider="heartbeat" type="Dummy">
    <operations>
      <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20"/>
      <op id="R-monitor-interval-11" interval="11" name="monitor" timeout="20">
        <instance_attributes id="R-monitor-interval-11-instance_attributes">
          <nvpair id="R-monitor-interval-11-instance_attributes-OCF_CHECK_LEVEL" name="OCF_CHECK_LEVEL" value="10"/>
        </instance_attributes>
      </op>
      <op id="R-start-interval-0s" interval="0s" name="start" timeout="20"/>
      <op id="R-stop-interval-0s" interval="0s" name="stop" timeout="20"/>
    </operations>
  </primitive>

> limited support of attribute "depth"
Attribute depth is not supported on the command line. For the backward compatibility we keep support for "OCF_CHECK_LEVEL" on the command line. The attribute "depth" could be confusing beside "OCF_CHECK_LEVEL".

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

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

[vm-rhel72-1 ~] $ cp /usr/lib/ocf/resource.d/heartbeat/Dummy /usr/lib/ocf/resource.d/heartbeat/Dummy.backup

[vm-rhel72-1 ~] $ sed -i 's/\(<action name="monitor".*\)$/\1\n<action name="monitor" timeout="20" interval="15" depth="10"\/>/' /usr/lib/ocf/resource.d/heartbeat/Dummy
[vm-rhel72-1 ~] $ cat /usr/lib/ocf/resource.d/heartbeat/Dummy | grep '<action name="monitor"'
<action name="monitor"      timeout="20" interval="10" depth="0" />
<action name="monitor" timeout="20" interval="15" depth="10"/>

[vm-rhel72-1 ~] $ pcs resource create R ocf:heartbeat:Dummy
[vm-rhel72-1 ~] $ pcs cluster cib|grep 'id="R-monitor-interval-15"' -A4
          <op id="R-monitor-interval-15" interval="15" name="monitor" timeout="20">
            <instance_attributes id="R-monitor-interval-15-instance_attributes">
              <nvpair id="R-monitor-interval-15-instance_attributes-OCF_CHECK_LEVEL" name="OCF_CHECK_LEVEL" value="10"/>
            </instance_attributes>
          </op>

[vm-rhel72-1 ~] $ mv /usr/lib/ocf/resource.d/heartbeat/Dummy.backup /usr/lib/ocf/resource.d/heartbeat/Dummy

Comment 8 Ivan Devat 2017-07-21 07:15:58 UTC
*** Bug 1473356 has been marked as a duplicate of this bug. ***

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