Bug 1126835

Summary: cibadmin --scope resources: Update does not conform to the configured schema
Product: Red Hat Enterprise Linux 6 Reporter: michal novacek <mnovacek>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.6CC: cluster-maint, dvossel, rsteiger, tojeline
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.138-1.el6 Doc Type: Bug Fix
Doc Text:
Cause: User exports a CIB to a file, makes multiple changes in it and pushes it back to the cluster. Consequence: If a cluster configuration is changed in the meantime the CIB will be rejected as outdated. Fix: Provide a scope=configuration option (and --config as a shortcut) to CIB related commands. Result: User is able to push a CIB to a cluster even if the cluster configuration has been changed in the meantime.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 06:15:36 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
Added full output of the commands in "Steps to reproduce"
none
resources-cibadmin file from reproducer
none
resources-cibadmin file from reproduces
none
proposed fix none

Description michal novacek 2014-08-05 12:05:34 UTC
Created attachment 924190 [details]
Added full output of the commands in "Steps to reproduce"

Description of problem:
Pushing back <resources> only xml to the cluster using 
"cibadmin --scope=resources --replace" fails with 
Call cib_replace failed (-203): Update does not conform to the configured schema

The reasen behind doing it this way is that it is much faster to perform the
changes against local file and than push all of them in one commit.

Version-Release number of selected component (if applicable):
pacemaker-cli-1.1.12-4.el6.x86_64
pacemaker-1.1.12-4.el6.x86_64

How reproducible: always

Steps to Reproduce:
1. cibadmin -Q --scope=resources > /tmp/resources-cibadmin
2. pcs cluster cib /tmp/cluster-cib
3. pcs -f /tmp/cluster-cib resource delete fs1
4. sed -i -n "/<resources/,/<\/resources/p" /tmp/cluster-cib
5. cibadmin --replace --scope resources --xml-file /tmp/cluster-cib

Actual results: xml not push to the cluster

Expected results: cluster configuration changed according to the xml

Additional info:

Full commands output attached as cluster-full-output.

Comment 1 michal novacek 2014-08-05 12:06:21 UTC
Created attachment 924191 [details]
resources-cibadmin file from reproducer

Comment 2 michal novacek 2014-08-05 12:06:56 UTC
Created attachment 924192 [details]
resources-cibadmin file from reproduces

Comment 4 Andrew Beekhof 2014-08-07 00:20:42 UTC
The replace fails because there are still constraints referencing 'fs1'.

I see this from pcs:

Removing fs1 from set pcs_rsc_set_nfsserver-clone_fs1
Removing fs1 from set pcs_rsc_set_nfsserver-clone_fs1-1
Removing fs1 from set pcs_rsc_set_export1_fs1
Removing fs1 from set pcs_rsc_set_fs1_export1
Deleting Resource (and group) - shared-fs2

but it doesn't look like this actually occurred.

Bouncing to Chris.

Comment 6 Tomas Jelinek 2014-11-06 16:35:35 UTC
Pcs removes the deleted resource from the constraints.  But it does not matter because only the "resources" element has been pushed back into pacemaker.  See step 4 and 5 in reproducer.  Please note that in the attached reproducer the pcs operates on the whole cib while in the "steps to reproduce" it operates only on the "resources" element so there is no way for pcs to update the constraints.


Summary of the discussion with QE:
1. Missing support for batch operations in pcs.  When user wants to create multiple resources and constraints he/she creates resources one by one and then creates the constraints.  Created resources are started on nodes across the cluster and then moved based on the constraints created later.  With batch operation support user would be able to create all the resources and constraints atomically (from the pacemaker point of view) thus prevent moving of the resources.

2. That leads user to export the cib to a file, make changes on that file and then push it back to pacemaker.  This is not reliable because "Call cib_replace failed (-205): Update was older than existing configuration" error can happen.

3. User tries to workaround by using the scope which leads to issue described in this bug.

4. Proposed solution: 'pcs cluster edit', 'pcs cluster cib' and 'pcs cluster cib-push' command should operate with --scope=configuration unless specified by the user otherwise (e.g. scope=cib to work with the whole cib).  Then user will not get the "Update was older" error when pushing the cib back to pacemaker and will not be bothered by the "status" section of the cib which should not be edited anyway and is confusing for most of the users.

Opinions?

Comment 7 michal novacek 2014-11-20 13:23:11 UTC
I like very much what Tomas proposed as solution in comment #6 and I would like it to be implemented. It seems like clever solution to the problem.

Comment 9 Tomas Jelinek 2014-11-26 16:13:45 UTC
Making 'configuration' the default scope would break backwards compatibility as the current scope is the whole cib.  The other option is to leave 'cib' as the default scope and add support for scope 'configuration'.  (The commands already have a scope options - see bz1115537)

Comment 10 Tomas Jelinek 2015-01-06 12:19:30 UTC
Created attachment 976783 [details]
proposed fix

Test:

[root@rh70-node1:~]# pcs cluster cib --config
{only the configuration section of the cib is displayed, no cib nor status element}
[root@rh70-node1:~]# pcs cluster cib scope=configuration
{only the configuration section of the cib is displayed, no cib nor status element}

[root@rh70-node1:~]# pcs cluster edit --config
{only the configuration section of the cib is shown in an editor, no cib nor status element}
[root@rh70-node1:~]# pcs cluster edit scope=configuration
{only the configuration section of the cib is shown in an editor, no cib nor status element}

[root@rh70-node1:~]# pcs resource create dummy dummy fake=aaaaa
[root@rh70-node1:~]# sed s/aaaaa/bbbbb/ -i /tmp/cib.xml
[root@rh70-node1:~]# sed 's/epoch="[0-9]*"/epoch="0"/g' -i /tmp/cib.xml
[root@rh70-node1:~]# pcs cluster cib-push /tmp/cib.xml
Error: unable to push cib
Call cib_replace failed (-205): Update was older than existing configuration
[root@rh70-node1:~]# pcs cluster cib-push /tmp/cib.xml --config
CIB updated
[root@rh70-node1:~]# pcs cluster cib-push /tmp/cib.xml scope=configuration
CIB updated

Comment 11 Tomas Jelinek 2015-01-27 13:54:46 UTC
Before Fix:
[root@rh66-node1 ~]# rpm -q pcs
pcs-0.9.123-9.el6.x86_64

[root@rh66-node1:~]# pcs cluster cib --config
option --config not recognized

Usage: pcs [-f file] [-h] [commands]...
...
[root@rh66-node1:~]# pcs cluster cib scope=configuration
[root@rh66-node1:~]# ls scope*
scope=configuration


[root@rh66-node1:~]# pcs cluster edit --config
option --config not recognized

Usage: pcs [-f file] [-h] [commands]...
[root@rh66-node1:~]# EDITOR=head pcs cluster edit scope=configuration
<cib crm_feature_set="3.0.9" validate-with="pacemaker-2.0" epoch="20" num_updates="9" admin_epoch="0" cib-last-written="Mon Jan 26 16:34:08 2015" have-quorum="1" dc-uuid="rh66-node2">
  <configuration>
    <crm_config>
      <cluster_property_set id="cib-bootstrap-options">
        <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.11-97629de"/>
        <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="cman"/>
        <nvpair id="cib-bootstrap-options-last-lrm-refresh" name="last-lrm-refresh" value="1421853604"/>
      </cluster_property_set>
    </crm_config>
    <nodes>
CIB not updated, no changes detected


[root@rh66-node1:~]# pcs resource create dummy dummy fake=aaaaa
[root@rh66-node1:~]# pcs cluster cib /tmp/cib.xml
[root@rh66-node1:~]# sed s/aaaaa/bbbbb/ -i /tmp/cib.xml
[root@rh66-node1:~]# sed 's/epoch="[0-9]*"/epoch="0"/g' -i /tmp/cib.xml
[root@rh66-node1:~]# pcs cluster cib-push /tmp/cib.xml
Error: unable to push cib
Call cib_replace failed (-205): Update was older than existing configuration

[root@rh66-node1:~]# pcs cluster cib-push /tmp/cib.xml --config
option --config not recognized

Usage: pcs [-f file] [-h] [commands]...
...
[root@rh66-node1:~]# pcs cluster cib-push /tmp/cib.xml scope=configuration

Usage: pcs cluster [commands]...
...



After Fix:
[root@rh66-node1:~]# rpm -q pcs
pcs-0.9.138-1.el6.x86_64

[root@rh66-node1:~]# pcs cluster cib --config | head
<configuration>
  <crm_config>
    <cluster_property_set id="cib-bootstrap-options">
      <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.11-97629de"/>
      <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="cman"/>
      <nvpair id="cib-bootstrap-options-last-lrm-refresh" name="last-lrm-refresh" value="1421853604"/>
    </cluster_property_set>
  </crm_config>
  <nodes>
    <node id="rh66-node1" uname="rh66-node1"/>
[root@rh66-node1:~]# pcs cluster cib scope=configuration | head
<configuration>
  <crm_config>
    <cluster_property_set id="cib-bootstrap-options">
      <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.11-97629de"/>
      <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="cman"/>
      <nvpair id="cib-bootstrap-options-last-lrm-refresh" name="last-lrm-refresh" value="1421853604"/>
    </cluster_property_set>
  </crm_config>
  <nodes>
    <node id="rh66-node1" uname="rh66-node1"/>
[root@rh66-node1:~]# ls scope*
ls: cannot access scope*: No such file or directory


[root@rh66-node1:~]# EDITOR=head pcs cluster edit --config
<configuration>
  <crm_config>
    <cluster_property_set id="cib-bootstrap-options">
      <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.11-97629de"/>
      <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="cman"/>
      <nvpair id="cib-bootstrap-options-last-lrm-refresh" name="last-lrm-refresh" value="1421853604"/>
    </cluster_property_set>
  </crm_config>
  <nodes>
    <node id="rh66-node1" uname="rh66-node1"/>
CIB not updated, no changes detected
[root@rh66-node1:~]# EDITOR=head pcs cluster edit scope=configuration
<configuration>
  <crm_config>
    <cluster_property_set id="cib-bootstrap-options">
      <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.11-97629de"/>
      <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="cman"/>
      <nvpair id="cib-bootstrap-options-last-lrm-refresh" name="last-lrm-refresh" value="1421853604"/>
    </cluster_property_set>
  </crm_config>
  <nodes>
    <node id="rh66-node1" uname="rh66-node1"/>
CIB not updated, no changes detected


[root@rh66-node1:~]# pcs resource create dummy dummy fake=aaaaa
[root@rh66-node1:~]# pcs cluster cib /tmp/cib.xml
[root@rh66-node1:~]# sed s/aaaaa/bbbbb/ -i /tmp/cib.xml
[root@rh66-node1:~]# sed 's/epoch="[0-9]*"/epoch="0"/g' -i /tmp/cib.xml
[root@rh66-node1:~]# pcs cluster cib-push /tmp/cib.xml
Error: unable to push cib
Call cib_replace failed (-205): Update was older than existing configuration

[root@rh66-node1:~]# pcs cluster cib-push /tmp/cib.xml --config
CIB updated
[root@rh66-node1:~]# pcs cluster cib-push /tmp/cib.xml scope=configuration
CIB updated
[root@rh66-node1:~]# pcs resource show dummy
 Resource: dummy (class=ocf provider=heartbeat type=Dummy)
  Attributes: fake=bbbbb 
  Operations: start interval=0s timeout=20 (dummy-start-interval-0s)
              stop interval=0s timeout=20 (dummy-stop-interval-0s)
              monitor interval=10 timeout=20 (dummy-monitor-interval-10)

Comment 19 errata-xmlrpc 2015-07-22 06:15:36 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://rhn.redhat.com/errata/RHBA-2015-1446.html