Bug 1930578

Summary: crm_resource --restart fails to restart clone instances except instance 0
Product: Red Hat Enterprise Linux 8 Reporter: Reid Wahl <nwahl>
Component: pacemakerAssignee: Chris Lumens <clumens>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: low    
Version: 8.3CC: cluster-maint, kgaillot, msmazova
Target Milestone: rcKeywords: Triaged
Target Release: 8.7   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: pacemaker-2.1.3-1.el8 Doc Type: No Doc Update
Doc Text:
This issue will not occur if the user uses pcs to restart.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 09:42:25 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:

Description Reid Wahl 2021-02-19 08:18:44 UTC
Description of problem:

See the description below, but note that this applies to clones in general, not just to promotable clones.

Copied from comment 10 of BZ1925681:
~~~
I think we have additional problems with crm_resource's handling of clone instances (i.e., only using the first clone instance). The following test of the restart command is with the current master branch.

  * Clone Set: stateful-clone [stateful] (promotable):
    * Masters: [ node2 ]
    * Slaves: [ node1 ]

# crm_resource --restart --resource stateful --node node1
Performing update of 'target-role' on 'stateful-clone', the parent of 'stateful:0'
Set 'stateful-clone' option: id=stateful-clone-meta_attributes-target-role set=stateful-clone-meta_attributes name=target-role value=stopped
Waiting for 1 resources to stop:
 * stateful-clone
Performing delete of 'target-role' on 'stateful-clone', the parent of 'stateful:0'
Deleted 'stateful-clone' option: id=stateful-clone-meta_attributes-target-role name=target-role
Waiting for 1 resources to start again:
 * stateful-clone


# crm_resource --restart --resource stateful --node node2
stateful is not running on node2 and so cannot be restarted
crm_resource: Error performing operation: No such device or address

With trace enabled:
(resource_is_running_on)        trace: Resource stateful:0 is not running on: node2
stateful is not running on node2 and so cannot be restarted



cli_resource_restart has a similar issue to resource_search_list_default. It first checks whether rsc is running on the specified host. If not, it returns ENXIO. The problem is that the value of `rsc` is the one found earlier in main() by pe_find_resource_with_flags -- which, as we can see in comment 9, returns the first clone instance. Of course, this instance (stateful:0 in my example) will only be running on at most one node. So if stateful:0 is running on node 1 and stateful:1 is running on node 2, then an attempt to restart stateful on node 2 will fail.

    if(resource_is_running_on(rsc, host) == FALSE) {
        const char *id = rsc->clone_name?rsc->clone_name:rsc->id;
        if(host) {
            out->err(out, "%s is not running on %s and so cannot be restarted", id, host);
        } else {
            out->err(out, "%s is not running anywhere and so cannot be restarted", id);
        }
        return ENXIO;
    }
~~~

-----

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

pacemaker-2.0.4-6.el8_3.1

-----

How reproducible:

Always

-----

Steps to Reproduce:
1. Create a clone resource (e.g., named "stateful") with no constraints so that it's allowed to run on all nodes.
2. Run `crm_resource --restart` for the resource on each cluster node as shown in the Description. (E.g., `crm_resource --restart -r stateful -N node1`).

-----

Actual results:

The resource is restarted on only one node. On the other nodes, the command fails with "crm_resource: Error performing operation: No such device or address".

-----

Expected results:

The resource is restarted on each node when the command is run for that node.

Comment 1 Reid Wahl 2021-02-19 08:26:00 UTC
This works fine when `--resource stateful-clone` is used instead of `--resource stateful`. I didn't notice that at first.

Pcs uses the stateful-clone syntax automatically, so I'm reducing this BZ to Low sev/priority.

Comment 4 Chris Lumens 2022-02-21 19:34:15 UTC
Potential fix that might be worth checking out - https://github.com/ClusterLabs/pacemaker/pull/2645

Comment 6 Ken Gaillot 2022-05-19 23:14:43 UTC
Fixed upstream as of commit ac29bf6

Comment 10 Markéta Smazová 2022-06-24 13:40:33 UTC
verified as SanityOnly in pacemaker-2.1.3-2.el8

Comment 12 errata-xmlrpc 2022-11-08 09:42:25 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 (pacemaker 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/RHBA-2022:7573