Bug 1419661 - pcs incorrectly recognizes parts of the resource agent name containing the systemd service instance
Summary: pcs incorrectly recognizes parts of the resource agent name containing the sy...
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: pcs
Version: 7.2
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Ivan Devat
QA Contact: cluster-qe@redhat.com
Depends On:
TreeView+ depends on / blocked
Reported: 2017-02-06 16:47 UTC by Ivan Devat
Modified: 2017-10-23 20:25 UTC (History)
6 users (show)

Fixed In Version: pcs-0.9.156-1.el7
Doc Type: Bug Fix
Doc Text:
Cause: A resource agent name can contain systemd instance. Pcs considers a colon in systemd instance as the delimiter the "provider" part from the "type" part. The "provider" part is not allowed in the resource agent name when the "standard" part is "systemd". Consequence: Some pcs commands crash when the systemd instance with a colon is used in a resource agent name. Fix: Pcs does not consider a colon in systemd instance as the delimiter the "provider" part from the "type" part. Result: Pcs works well with the resource agent name that contains systemd instance with a colon.
Clone Of:
Last Closed: 2017-08-01 18:26:07 UTC
Target Upstream Version:

Attachments (Terms of Use)
proposed fix (11.97 KB, patch)
2017-02-10 12:44 UTC, Ivan Devat
no flags Details | Diff

System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1382364 0 medium CLOSED crm_resource does not list systemd services properly 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2017:1958 0 normal SHIPPED_LIVE pcs bug fix and enhancement update 2017-08-01 18:09:47 UTC

Internal Links: 1382364

Description Ivan Devat 2017-02-06 16:47:51 UTC
Description of problem:
Pcs accepts a resource agent name in the format "standard:provider:type" when "standard" is 'ocf', or "standard:type" otherwise. However we can get for example the name "systemd:lvm2-pvscan@252:2", see:

[vm-rhel72-1 ~] $ crm_resource --list-agents systemd|grep @

But the second colon in the name "systemd:lvm2-pvscan@252:2" does not separate a provider and a type. If such resource agent name is used in "pcs resource create" it produces an invalid cib.

How reproducible:

Steps to Reproduce:
[vm-rhel72-1 ~] $ pcs resource create X systemd:lvm2-pvscan@252:2

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

Expected results:
Success and
[vm-rhel72-1 ~] $ pcs cluster cib|grep 'primitive.*lvm2-pvscan' -A5
      <primitive class="systemd" id="X" type="lvm2-pvscan@252:2">
        <instance_attributes id="X-instance_attributes"/>
          <op id="X-monitor-interval-60s" interval="60s" name="monitor"/>

Additional info:
In the current upstream version this bug is partially corrected and we get:
[vm-rhel72-1 ~] $ pcs resource create X systemd:lvm2-pvscan@252:2
Error: Invalid resource agent name 'systemd:lvm2-pvscan@252:2'. Use standard:provider:type when standard is 'ocf' or standard:type otherwise. List of standards and providers can be obtained by using commands 'pcs resource standards' and 'pcs resource providers'

Pcs validates the resource agent name and prevents to produce an invalid cib. But the behaviour is not correct. Moreover this validation is not correct and as a side effect it breaks the "pcs resource list" command.
[vm-rhel72-1 ~] $ pcs resource list systemd --nodesc
Traceback (most recent call last):
  File "/root/pcs/pcs/pcs", line 12, in <module>
  File "/root/pcs/pcs/app.py", line 191, in main
  File "/root/pcs/pcs/resource.py", line 49, in resource_cmd
    resource_list_available(lib, argv_next, modifiers)
  File "/root/pcs/pcs/resource.py", line 214, in resource_list_available
    agent_list = lib.resource_agent.list_agents(modifiers["describe"], search)
  File "/root/pcs/pcs/cli/common/lib_wrapper.py", line 96, in decorated_run
    return run_with_middleware(run, cli_env, *args, **kwargs)
  File "/root/pcs/pcs/cli/common/middleware.py", line 20, in run
    return next_in_line(env, *args, **kwargs)
  File "/root/pcs/pcs/cli/common/lib_wrapper.py", line 86, in run
    lib_call_result = run_library_command(lib_env, *args, **kwargs)
  File "/root/pcs/pcs/lib/commands/resource_agent.py", line 75, in list_agents
  File "/root/pcs/pcs/lib/commands/resource_agent.py", line 93, in _complete_agent_list
    agent_metadata = metadata_class(runner, name)
  File "/root/pcs/pcs/lib/resource_agent.py", line 637, in __init__
    self._name_parts = self._prepare_name_parts(name)
  File "/root/pcs/pcs/lib/resource_agent.py", line 703, in _prepare_name_parts
    return get_resource_agent_name_from_string(name)
  File "/root/pcs/pcs/lib/resource_agent.py", line 111, in get_resource_agent_name_from_string
    raise InvalidResourceAgentName(full_agent_name)

Comment 2 Tomas Jelinek 2017-02-07 08:46:34 UTC
We should also take a look at ResourceAgent class in pcsd/resource.rb.

Comment 3 Ivan Devat 2017-02-10 12:44:09 UTC
Created attachment 1249034 [details]
proposed fix

Tests are in the patch.

Comment 4 Ivan Devat 2017-02-20 08:27:01 UTC
After Fix:

[vm-rhel72-1 ~] $ rpm -q pcs

[vm-rhel72-1 ~] $ crm_resource --list-agents systemd|grep @252:

> pcs resource list

[vm-rhel72-1 ~] $ pcs resource list systemd --nodesc|grep @252:

> resource create

[vm-rhel72-1 ~] $ pcs resource create R systemd:lvm2-pvscan@252:2
[vm-rhel72-1 ~] $ pcs cluster cib|grep 'primitive.*id="R"'
      <primitive class="systemd" id="R" type="lvm2-pvscan@252:2">

> webui

Open web UI. Go to "RESOURCES" tab. Click "Add". In "Add Resource" dialog:
* There is only the "systemd" value in the combo "Class/Provider". There is not the value "systemd:lvm2-pvscan@252".
* Select the value "systemd" in the combo "Class/Provider". In the combo "Type" there is the value "lvm2-pvscan@252:2"

Comment 8 errata-xmlrpc 2017-08-01 18:26:07 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.


Comment 9 Radek Steiger 2017-10-23 20:25:41 UTC
Please be aware that due to a pacemaker change via bz1382364 the 'pcs resource list' command will now only list service units, not service unit instances:

[root@virt-280 ~]# pcs resource list systemd:lvm2-pvscan@252:2
Error: No resource agents matching the filter.

Omitting the instance works as expected:

[root@virt-280 ~]# pcs resource list systemd:lvm2-pvscan@
systemd:lvm2-pvscan@ - systemd unit file for lvm2-pvscan@

[root@virt-280 ~]# pcs resource list systemd:lvm2-pvscan
systemd:lvm2-pvscan@ - systemd unit file for lvm2-pvscan@

Note You need to log in before you can comment on or make changes to this bug.