Bug 1447349

Summary: "resource group add" produces invalid cib when group id is already occupied with non-resource element
Product: Red Hat Enterprise Linux 7 Reporter: Radek Steiger <rsteiger>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: high    
Version: 7.4CC: cfeist, cluster-maint, cluster-qe, idevat, mlisik, omular, tojeline
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.167-1.el7 Doc Type: Bug Fix
Doc Text:
Cause: The user wants to create a resource group and uses an id of a non-group element as the group's name. Consequence: Pcs dumps an invalid CIB to a terminal. Fix: Check if the specified group name is already used as an id of an element in the CIB. Result: Pcs gracefully exits with an error explaining the specified group name already exists and cannot be used.
Story Points: ---
Clone Of: 1382004
: 1668223 (view as bug list) Environment:
Last Closed: 2019-08-06 13:10:01 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 + test none

Description Radek Steiger 2017-05-02 13:33:35 UTC
+++ This bug was initially created as a clone of Bug #1382004 +++

Description of problem:
"pcs resource create" produces invalid cib when group id is already occupied with non-resource element.

How reproducible: always


Steps to Reproduce:
1.
> chose some non-resource element id.
[vm-rhel72-1 ~] $ pcs cluster cib | grep "id=\"cib-bootstrap-options-cluster-name\""
        <nvpair id="cib-bootstrap-options-cluster-name" name="cluster-name" value="devcluster"/>
2.
> try use it as group with "pcs resource create"
[vm-rhel72-1 ~] $ pcs resource create dummy Dummy --group cib-bootstrap-options-cluster-name

Actual results:
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib...

Expected results:
Error: 'cib-bootstrap-options-cluster-name' cannot be used as group name (is already used as name for another element)

Additional info:
The same problem is with "pcs resource group add" command, for example:

[vm-rhel72-1 ~] $ pcs resource | grep D1
 D1     (ocf::heartbeat:Dummy): Started vm-rhel72-3
[vm-rhel72-1 ~] $ pcs resource group add cib-bootstrap-options-cluster-name D1
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib...

Comment 1 Radek Steiger 2017-05-02 13:37:02 UTC
The same bug exists in adding a resource into a group with 'pcs resource group add ...' command:


[root@host-030 ~]# pcs resource group add fence-host-031-instance_attributes-pcmk_host_check dummy2
Error: Unable to update cib
Call cib_replace failed (-203): Update does not conform to the configured schema
<cib crm_feature_set="3.0.12" validate-with="pacemaker-2.6" epoch="1095" num_updates="0" admin_epoch="0" cib-last-written="Sat Apr 29 16:48:30 2017" update-origin="host-030" update-client="cibadmin" update-user="root" have-quorum="1" dc-uuid="1">
  <configuration>
    <crm_config>


[root@host-030 ~]# pcs resource group add fence-host-031-instance_attributes-pcmk_host_check dummy2 2>&1 | grep fence-host-031-instance_attributes-pcmk_host_check
          <nvpair id="fence-host-031-instance_attributes-pcmk_host_check" name="pcmk_host_check" value="static-list"/>
      <group id="fence-host-031-instance_attributes-pcmk_host_check">

Comment 2 Tomas Jelinek 2019-02-08 12:57:26 UTC
Created attachment 1528079 [details]
proposed fix + test

Reproducer in [comment 1].

Comment 3 Ivan Devat 2019-03-21 10:00:36 UTC
After Fix:

[kid76 ~] $ rpm -q pcs
pcs-0.9.167-1.el7.x86_64

[kid76 ~] $ pcs resource create R ocf:heartbeat:Dummy
[kid76 ~] $ pcs cluster cib|grep R-stop-interval-0s
          <op id="R-stop-interval-0s" interval="0s" name="stop" timeout="20s"/>
[kid76 ~] $ pcs resource group add R-stop-interval-0s R
Error: Group 'R-stop-interval-0s' does not exists and cannot be created since the id 'R-stop-interval-0s' already exists in the cib
[kid76 ~] $  pcs resource create R2 ocf:heartbeat:Dummy --group R-stop-interval-0s
Error: 'R-stop-interval-0s' is not a group

Comment 7 errata-xmlrpc 2019-08-06 13:10:01 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-2019:2244