Bug 1402475

Summary: "resource create" with flags "--clone" and "--disable" puts metadata for disabling inappropriately
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: low    
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: Pcs incorrectly puts metadata for disabling the resource when the user runs "pcs resource create" with flags "--clone" and "--disabled". Consequence: Pcs puts into the cib a different contents than the user expected. Fix: Correct the placement of metadata for disabling resource. Result: Pcs puts a correct contents into the cib.
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-12-07 15:55:39 UTC
Description of problem:
"resource create" with flags --clone and --disable puts metadata for disabling inappropriately. It puts it as primitive meta_attributes.


How reproducible:
always


Steps to Reproduce:

[vm-rhel72-1 ~] $ pcs resource create R1 ocf:heartbeat:Dummy --clone --disabled --no-default-ops

Actual results:
In cib, there is:
...
<clone id="R1-clone">
  <primitive class="ocf" id="R1" provider="heartbeat" type="Dummy">
    <instance_attributes id="R1-instance_attributes"/>
    <meta_attributes id="R1-meta_attributes">
      <nvpair id="R1-meta_attributes-target-role" name="target-role" value="Stopped"/>
    </meta_attributes>
    <operations>
      <op id="R1-monitor-interval-60s" interval="60s" name="monitor"/>
    </operations>
  </primitive>
  <meta_attributes id="R1-clone-meta_attributes"/>
</clone>
...


Expected results:
in cib:
...
<clone id="R1-clone">
  <primitive class="ocf" id="R1" provider="heartbeat" type="Dummy">
    <instance_attributes id="R1-instance_attributes"/>
    <operations>
      <op id="R1-monitor-interval-60s" interval="60s" name="monitor"/>
    </operations>
  </primitive>
  <meta_attributes id="R1-clone-meta_attributes">
    <nvpair id="R1-clone-meta_attributes-target-role" name="target-role" value="Stopped"/>
  </meta_attributes>
</clone>
...


Additional info:
Metadata are placed appropriately when is used --master instead of --clone:

[vm-rhel72-1 ~] $ pcs resource create R2 ocf:heartbeat:Dummy --master --disabled --no-default-ops
in cib:
...
<master id="R2-master">
  <primitive class="ocf" id="R2" provider="heartbeat" type="Dummy">
    <instance_attributes id="R2-instance_attributes"/>
    <operations>
      <op id="R2-monitor-interval-60s" interval="60s" name="monitor"/>
    </operations>
  </primitive>
  <meta_attributes id="R2-master-meta_attributes">
    <nvpair id="R2-master-meta_attributes-target-role" name="target-role" value="Stopped"/>
  </meta_attributes>
</master>
...


Metadata are placed appropriately when clone is created as enabled and then disabled:

[vm-rhel72-1 ~] $ pcs resource create R3 ocf:heartbeat:Dummy --clone --no-default-ops
[vm-rhel72-1 ~] $ pcs resource disable R3
in cib:
...
<clone id="R3-clone">
  <primitive class="ocf" id="R3" provider="heartbeat" type="Dummy">
    <instance_attributes id="R3-instance_attributes"/>
    <operations>
      <op id="R3-monitor-interval-60s" interval="60s" name="monitor"/>
    </operations>
  </primitive>
  <meta_attributes id="R3-clone-meta_attributes">
    <nvpair id="R3-clone-meta_attributes-target-role" name="target-role" value="Stopped"/>
  </meta_attributes>
</clone>
...

Comment 2 Ivan Devat 2017-01-31 16:33:43 UTC
Created attachment 1246362 [details]
proposed fix

Tests are in the patch.

Comment 3 Ivan Devat 2017-02-20 08:07:12 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 --clone --disabled
[vm-rhel72-1 ~] $ pcs cluster cib|grep 'id="R-clone"' -A11
      <clone id="R-clone">
        <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-start-interval-0s" interval="0s" name="start" timeout="20"/>
            <op id="R-stop-interval-0s" interval="0s" name="stop" timeout="20"/>
          </operations>
        </primitive>
        <meta_attributes id="R-clone-meta_attributes">
          <nvpair id="R-clone-meta_attributes-target-role" name="target-role" value="Stopped"/>
        </meta_attributes>
      </clone>

Comment 7 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