Bug 1387106

Summary: pcs fails when uses a non-ascii output from external program
Product: Red Hat Enterprise Linux 6 Reporter: Ivan Devat <idevat>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: high    
Version: 6.8CC: cfeist, cluster-maint, idevat, omular, rsteiger, tojeline
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.155-1.el6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 11:04:40 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 none

Description Ivan Devat 2016-10-20 06:33:02 UTC
Description of problem:
pcs fails when it uses a non-ascii output from an external program. This may be due to locales.


Steps to Reproduce:

> ensure sbd is not a recognized service
[vm-rhel67-1 ~] $ service sbd status
sbd: unrecognized service

> ensure "pcs status" works
[vm-rhel67-1 ~] $ pcs status
Cluster name: devcluster6
Last updated: Wed Oct 19 16:19:15 2016          Last change: Wed Oct 19 16:19:09 2016 by root via cibadmin on vm-rhel67-1
Stack: cman
Current DC: vm-rhel67-1 (version 1.1.14-8.el6_8.1-70404b0) - partition with quorum
2 nodes and 1 resource configured

Online: [ vm-rhel67-1 vm-rhel67-2 ]

Full list of resources:

 xvm-fencing    (stonith:fence_xvm):    Started vm-rhel67-1

> change LANG to get non-ascii characters
[vm-rhel67-1 ~] $ export LANG=cs_CZ.UTF-8
[vm-rhel67-1 ~] $ service sbd status
sbd: neznámá služba

> run "pcs status"
[vm-rhel67-1 ~] $ pcs status


Actual results:

Cluster name: devcluster6
Traceback (most recent call last):
  File "/usr/sbin/pcs", line 9, in <module>
    load_entry_point('pcs==0.9.154', 'console_scripts', 'pcs')()
  File "/usr/lib/python2.6/site-packages/pcs/app.py", line 216, in main
    cmd_map[command](argv)
  File "/usr/lib/python2.6/site-packages/pcs/status.py", line 24, in status_cmd
    full_status()
  File "/usr/lib/python2.6/site-packages/pcs/status.py", line 91, in full_status
    if utils.stonithCheck():
  File "/usr/lib/python2.6/site-packages/pcs/utils.py", line 1944, in stonithCheck
    if is_service_running(cmd_runner(), "sbd"):
  File "/usr/lib/python2.6/site-packages/pcs/lib/external.py", line 274, in is_service_running
    ["service", service, "status"]
  File "/usr/lib/python2.6/site-packages/pcs/lib/external.py", line 414, in run
    out_err=out_err
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)


Expected results:

Cluster name: devcluster6
Last updated: Wed Oct 19 16:19:15 2016          Last change: Wed Oct 19 16:19:09 2016 by root via cibadmin on vm-rhel67-1
Stack: cman
Current DC: vm-rhel67-1 (version 1.1.14-8.el6_8.1-70404b0) - partition with quorum
2 nodes and 1 resource configured

Online: [ vm-rhel67-1 vm-rhel67-2 ]

Full list of resources:

 xvm-fencing    (stonith:fence_xvm):    Started vm-rhel67-1

Comment 2 Tomas Jelinek 2016-10-20 07:11:08 UTC
pcs often parses output of external tools and we need to make sure the messages are in a defined language.

Comment 5 Tomas Jelinek 2016-10-20 13:42:27 UTC
Created attachment 1212519 [details]
proposed fix

It is essential to remove all fence devices from the cluster otherwise the reproducer does not work.



Test:
# LC_ALL=cs_CZ.UTF8 pcs status 
Cluster name: cluster68
WARNING: no stonith devices and stonith-enabled is not false
Stack: cman
Current DC: rh68-node1 (version 1.1.15-1.el6-e174ec8) - partition with quorum
Last updated: Thu Oct 20 15:40:15 2016          Last change: Thu Oct 20 15:35:28 2016 by root via cibadmin on rh68-node2

2 nodes and 0 resources configured

Online: [ rh68-node1 rh68-node2 ]

No resources


Daemon Status:
  cman: active/disabled
  corosync: active/disabled
  pacemaker: active/enabled
  pcsd: active/enabled

Comment 6 Ivan Devat 2016-11-07 15:37:11 UTC
Before Fix:

[vm-rhel67-1 ~] $ rpm -q pcs
pcs-0.9.154-1.el6.x86_64

> ensure sbd is not a recognized service

[vm-rhel67-1 ~] $ service sbd status
sbd: unrecognized service

> have a cluster without fence devices

[vm-rhel67-1 ~] $ pcs status|grep "no stonith device"
WARNING: no stonith devices and stonith-enabled is not false

[vm-rhel67-1 ~] $ LC_ALL=cs_CZ.UTF8 pcs status
Cluster name: devcluster6
Traceback (most recent call last):
  File "/usr/sbin/pcs", line 9, in <module>
    load_entry_point('pcs==0.9.154', 'console_scripts', 'pcs')()
  File "/usr/lib/python2.6/site-packages/pcs/app.py", line 216, in main
    cmd_map[command](argv)
  File "/usr/lib/python2.6/site-packages/pcs/status.py", line 24, in status_cmd
    full_status()
  File "/usr/lib/python2.6/site-packages/pcs/status.py", line 91, in full_status
    if utils.stonithCheck():
  File "/usr/lib/python2.6/site-packages/pcs/utils.py", line 1944, in stonithCheck
    if is_service_running(cmd_runner(), "sbd"):
  File "/usr/lib/python2.6/site-packages/pcs/lib/external.py", line 274, in is_service_running
    ["service", service, "status"]
  File "/usr/lib/python2.6/site-packages/pcs/lib/external.py", line 414, in run
    out_err=out_err
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)


After Fix:

[vm-rhel67-1 ~] $ rpm -q pcs
pcs-0.9.155-1.el6.x86_64
[vm-rhel67-1 ~] $ service sbd status
sbd: unrecognized service
[vm-rhel67-1 ~] $ pcs status|grep "no stonith device"
WARNING: no stonith devices and stonith-enabled is not false
[vm-rhel67-1 ~] $ LC_ALL=cs_CZ.UTF8 pcs status
Cluster name: devcluster6
WARNING: no stonith devices and stonith-enabled is not false
Stack: cman
Current DC: vm-rhel67-1 (version 1.1.15-2.el6-e174ec8) - partition with quorum
Last updated: Mon Nov  7 15:37:31 2016          Last change: Mon Nov  7 15:36:54 2016 by root via crmd on vm-rhel67-1

2 nodes and 0 resources configured

Online: [ vm-rhel67-1 vm-rhel67-2 ]

No resources


Daemon Status:
  cman: active/disabled
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/disabled

Comment 10 errata-xmlrpc 2017-03-21 11:04:40 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://rhn.redhat.com/errata/RHBA-2017-0707.html