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...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: pcs
Version: 7.2
Hardware: Unspecified
OS: Unspecified
urgent
unspecified
Target Milestone: rc
: ---
Assignee: Ivan Devat
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
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:
Environment:
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


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:1958 normal SHIPPED_LIVE pcs bug fix and enhancement update 2017-08-01 18:09:47 UTC
Red Hat Bugzilla 1382364 None CLOSED crm_resource does not list systemd services properly 2019-05-03 17:43:54 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 @
lvm2-pvscan@252:2

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:
always


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
<cib


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"/>
        <operations>
          <op id="X-monitor-interval-60s" interval="60s" name="monitor"/>
        </operations>
      </primitive>


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>
    app.main(sys.argv[1:])
  File "/root/pcs/pcs/app.py", line 191, in main
    cmd_map[command](argv)
  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
    resource_agent.ResourceAgent
  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)
pcs.lib.resource_agent.InvalidResourceAgentName

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
pcs-0.9.156-1.el7.x86_64

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

> pcs resource list

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

> 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.

https://access.redhat.com/errata/RHBA-2017:1958

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.