Bug 1741056

Summary: [RFE] Make it possible to set custom (promotable) clone id
Product: Red Hat Enterprise Linux 8 Reporter: Tomas Jelinek <tojeline>
Component: pcsAssignee: Miroslav Lisik <mlisik>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact: Steven J. Levine <slevine>
Priority: medium    
Version: 8.1CC: cfeist, cluster-maint, idevat, mlisik, mmazoure, nhostako, omular, slevine, tojeline
Target Milestone: rcKeywords: FutureFeature
Target Release: 8.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.10.7-1.el8 Doc Type: Enhancement
Doc Text:
.Ability to specify a custom clone ID when creating a clone resource or promotable clone resource When you create a clone resource or a promotable clone resource, the clone resource is named _resource-id_ `-clone` by default. If that ID is already in use, PCS adds the suffix -_integer_, starting with an integer value of `1` and incrementing by one for each additional clone. You can now override this default by specifying a name for a clone resource ID or promotable clone resource ID with the _clone-id_ option when creating a clone resource with the `pcs resource create` or the `pcs resource clone` command. For information on creating clone resources, see link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_high_availability_clusters/assembly_creating-multinode-resources-configuring-and-managing-high-availability-clusters[Creating cluster resources that are active on multiple nodes].
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:12:05 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 + tests
none
additional fix none

Description Tomas Jelinek 2019-08-14 07:37:51 UTC
Description of problem:
When creating a (promotable) clone resource, pcs automatically sets its id to <primitive resource name>-clone. If that id is already taken, pcs adds -<integer> suffix to the id to make it unique starting with <integer> == 1 and counting up.

This causes issues when scripting as one must figure out what the clone id is. It would be much easier for scripts to be able to set custom clone id.

This feature was requested in upstream IRC.


Version-Release number of selected component (if applicable):
pcs-0.10.2


How reproducible:
always, easily


Actual results:
No way to set custom (promotable) clone id.


Expected results:
Be able to set custom (promotable) clone id.


Additional info:

Proposed syntax variants:

1. clone | promotable <resource id> [<clone id>] [<clone options>]
To distinguish clone id from the first clone options, look for = in the first arg after resource id. That means clone id cannot contain =.

2. clone | promotable <resource id> [id=<clone id>] [<clone options>]
Clone id is effectively a clone option. This will not work if there is an actual id option.

Comment 1 Miroslav Lisik 2020-09-21 15:11:33 UTC
Created attachment 1715552 [details]
proposed fix + tests

Affected commands:
* pcs resource create ... clone
* pcs resource create ... promotable
* pcs resource clone
* pcs resource promotable

Test:

[root@r8-node-01 pcs]# pcs resource create c1 ocf:pacemaker:Dummy clone MyCloneId globally-unique=true
[root@r8-node-01 pcs]# pcs resource create p1 ocf:pacemaker:Stateful promotable MyPromotableId
[root@r8-node-01 pcs]# pcs resource
  * Clone Set: MyCloneId [c1] (unique):
    * c1:0      (ocf::pacemaker:Dummy):  Started r8-node-01
    * c1:1      (ocf::pacemaker:Dummy):  Started r8-node-02
  * Clone Set: MyPromotableId [p1] (promotable):
    * Masters: [ r8-node-01 ]
    * Slaves: [ r8-node-02 ]
[root@r8-node-01 pcs]# pcs resource unclone MyCloneId
[root@r8-node-01 pcs]# pcs resource unclone MyPromotableId
[root@r8-node-01 pcs]# pcs resource
  * c1  (ocf::pacemaker:Dummy):  Started r8-node-01
  * p1  (ocf::pacemaker:Stateful):       Started r8-node-02
[root@r8-node-01 pcs]# pcs resource clone c1 ClonedDummy
[root@r8-node-01 pcs]# pcs resource clone p1 PromotableStateful
[root@r8-node-01 pcs]# pcs resource
  * Clone Set: ClonedDummy [c1]:
    * Started: [ r8-node-01 r8-node-02 ]
  * Clone Set: PromotableStateful [p1]:
    * Started: [ r8-node-01 r8-node-02 ]
[root@r8-node-01 pcs]# pcs resource create c2 ocf:pacemaker:Dummy clone ClonedDummy
Error: 'ClonedDummy' already exists
Error: Errors have occurred, therefore pcs is unable to continue
[root@r8-node-01 pcs]# echo $?
1

Comment 2 Miroslav Lisik 2020-09-22 11:54:13 UTC
Created attachment 1715687 [details]
additional fix

Add missing '>' to the 'pcs resource clone' help.

[root@r8-node-01 pcs]# pcs resource clone --help

Usage: pcs resource clone...
    clone <resource id | group id> [<clone id>] [clone options]... [--wait[=n]]
        Set up the specified resource or group as a clone. If --wait is
        specified, pcs will wait up to 'n' seconds for the operation to finish
        (including starting clone instances if appropriate) and then return 0
        on success or 1 on error. If 'n' is not specified it defaults to 60
        minutes.

Comment 6 Miroslav Lisik 2020-10-14 13:50:05 UTC
Test:

[root@r8-node-01 ~]# rpm -q pcs
pcs-0.10.7-1.el8.x86_64

[root@r8-node-01 ~]# pcs resource create c1 ocf:pacemaker:Dummy clone MyCloneId globally-unique=true
[root@r8-node-01 ~]# pcs resource
  * Clone Set: MyCloneId [c1] (unique):
    * c1:0      (ocf::pacemaker:Dummy):  Started r8-node-01
    * c1:1      (ocf::pacemaker:Dummy):  Started r8-node-02

Comment 15 errata-xmlrpc 2021-05-18 15:12:05 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 (pcs bug fix and enhancement update), 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/RHEA-2021:1737