Bug 1115537

Summary: [RFE] 'pcs cluster cib': implement --scope as cibadmin does
Product: Red Hat Enterprise Linux 7 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: 7.0CC: cfeist, cluster-maint, rsteiger, slevine, tojeline
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.137-2.el7 Doc Type: Enhancement
Doc Text:
Feature: Provide a way to edit/view part of the CIB. Reason: User wants to view/edit only part of the CIB. Result: User is able to view/edit part of the CIB.
Story Points: ---
Clone Of:
: 1129871 1190168 (view as bug list) Environment:
Last Closed: 2015-03-05 09:20:11 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:
Bug Depends On:    
Bug Blocks: 1129871, 1190168    
Attachments:
Description Flags
proposed fix
none
proposed fix - error messages none

Description michal novacek 2014-07-02 14:46:01 UTC
Description of problem:
I have a cluster with a lot of resources which I wanted to frequently remove
and add again. To speed thing up I decided to use a cib, delete the resources
there and push it back. The usual workflow 'pcs cluster cib file.xml', modify
file.xml, 'pcs cluster cib-push file.xml' will fail most of the time an more
complex cluster configurations with "Application of an update diff failed
(-206)". This I believe is the correct behaviour but it is quite inconvenient.

Looking for the way on how to achieve this I found out that cibadmin is able to
check out only <resources> element from the cluster configuration using
'--scope resources' parameter. Using the following:

$ cibadmin -Q --scope resources > file.xml
edit file.xml
$ cibadmin --replace --scope resources --xml-file file.xml

I was able to update (remove) resources and add them back again easily. Also,
no version in such file. 

Request: Implement --scope {resources,constraints} to 'pcs cluster cib' and
'pcs clustert cib-push' to allow user easily modify and push back only
resources/constraints parts of the cluster configuration.

version: pcs-0.9.115-32.el7.x86_64

Comment 3 Tomas Jelinek 2014-10-02 08:51:26 UTC
Created attachment 943334 [details]
proposed fix

Test:

[root@rh70-node1:~]# pcs cluster cib scope=nodes
<nodes>
  <node id="1" uname="rh70-node1"/>
  <node id="2" uname="rh70-node2"/>
</nodes>


[root@rh70-node1:~]# pcs cluster edit scope=resources
{only the resources configuration is shown in an editor}


[root@rh70-node1:~]# pcs resource create dummy Dummy
[root@rh70-node1:~]# pcs constraint location dummy prefers rh70-node1
[root@rh70-node1:~]# pcs constraint
Location Constraints:
  Resource: dummy
    Enabled on: rh70-node1
Ordering Constraints:
Colocation Constraints:
[root@rh70-node1:~]# pcs resource
 dummy  (ocf::heartbeat:Dummy): Started 
[root@rh70-node1:~]# echo "<cib><configuration><resources/><constraints/></configuration></cib>" > cib.xml
[root@rh70-node1:~]# ./pcs cluster cib-push cib.xml scope=constraints
CIB updated
[root@rh70-node1:~]# pcs constraint
Location Constraints:
Ordering Constraints:
Colocation Constraints:
[root@rh70-node1:~/devel/pcs/pcs]# pcs resource
 dummy  (ocf::heartbeat:Dummy): Started

Comment 4 Tomas Jelinek 2014-10-14 11:14:23 UTC
Before Fix:
[root@rh70-node1 ~]# rpm -q pcs
pcs-0.9.115-32.el7.x86_64
[root@rh70-node1:~]# ls scope=nodes
ls: cannot access scope=nodes: No such file or directory
[root@rh70-node1:~]# pcs cluster cib scope=nodes
[root@rh70-node1:~]# ls scope=nodes
scope=nodes
[root@rh70-node1:~]# EDITOR=`which cat` pcs cluster edit scope=nodes
<cib admin_epoch="0" cib-last-written="Tue Oct 14 11:04:25 2014" crm_feature_set="3.0.9" epoch="7362" have-quorum="1" num_updates="2" update-client="cibadmin" update-origin="rh70-node1" validate-with="pacemaker-1.2" dc-uuid="2">
{whole cib gets printed, output trimmed}
[root@rh70-node1:~]#  pcs cluster cib-push cib.xml scope=constraints

Usage: pcs cluster [commands]...
Configure cluster for use with pacemaker
{output trimmed}


After Fix:
[root@rh70-node1:~]# rpm -q pcs
pcs-0.9.132-1.el7.x86_64
[root@rh70-node1:~]# pcs cluster cib scope=nodes
<nodes>
  <node id="1" uname="rh70-node1"/>
  <node id="2" uname="rh70-node2"/>
</nodes>
[root@rh70-node1:~]# EDITOR=`which cat` pcs cluster edit scope=nodes
<nodes>
  <node id="1" uname="rh70-node1"/>
  <node id="2" uname="rh70-node2"/>
</nodes>
CIB not updated, no changes detected
[root@rh70-node1:~]# pcs resource create dummy Dummy
[root@rh70-node1:~]# pcs constraint location dummy prefers rh70-node1
[root@rh70-node1:~]# echo "<cib><configuration><resources/><constraints/></configuration></cib>" > cib.xml
[root@rh70-node1:~]# pcs cluster cib-push cib.xml scope=constraints
CIB updated
[root@rh70-node1:~]# pcs constraint
Location Constraints:
Ordering Constraints:
Colocation Constraints:
[root@rh70-node1:~]# pcs resource
 dummy  (ocf::heartbeat:Dummy): Started

Comment 11 Tomas Jelinek 2014-12-08 15:48:54 UTC
Created attachment 965905 [details]
proposed fix - error messages

Before Fix:
[root@rh70-node1:~]# rpm -q pcs
pcs-0.9.137-1.el7.x86_64
[root@rh70-node1:~]# pcs cluster cib scope=rsc_defaults
Error: unable to get cib
[root@rh70-node1:~]# EDITOR=cat pcs cluster edit scope=rsc_defaults
Error: unable to get cib
[root@rh70-node1:~]# pcs cluster cib /tmp/cib.xml
[root@rh70-node1:~]# pcs cluster cib-push /tmp/cib.xml scope=rsc_defaults
Error: unable to push cib
Call cib_replace failed (-22): Invalid argument


After Fix:
[root@rh70-node1:~]# rpm -q pcs
pcs-0.9.137-2.el7.x86_64
[root@rh70-node1:~]# pcs cluster cib scope=rsc_defaults
Error: unable to get cib, scope 'rsc_defaults' not present in cib
[root@rh70-node1:~]# EDITOR=cat pcs cluster edit scope=rsc_defaults
Error: unable to get cib, scope 'rsc_defaults' not present in cib
[root@rh70-node1:~]# pcs cluster cib /tmp/cib.xml
[root@rh70-node1:~]# pcs cluster cib-push /tmp/cib.xml scope=rsc_defaults
Error: unable to push cib, scope 'rsc_defaults' not present in new cib

Comment 13 Jiri Herrmann 2014-12-12 15:31:49 UTC
If this Feature should be included in the 7.1 Release Notes, could you please change the Doc Type from Enhancement to "Release Note"?

Note that the Release Notes are intended to list the most prominent and customer-relevant new features rather than every single enhancement.

Cheers,
Jirka

Comment 14 Tomas Jelinek 2014-12-15 14:16:25 UTC
Jiri,
I think this feature is not important enough to be included in the Release Notes, it is a minor enhancement.

Comment 15 Steven J. Levine 2014-12-15 14:47:29 UTC
Just to follow up on what Tomas says here: The feature is minor enough in scope (and pretty much for testers rather than users) that we decided not to document it in the pcs reference manual either, as noted in BZ#1129871.

Comment 17 errata-xmlrpc 2015-03-05 09:20:11 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-0415.html