Bug 1741586

Summary: pcsd is unable to handle non-ASCII characters in corosync.conf
Product: Red Hat Enterprise Linux 8 Reporter: Nina Hostakova <nhostako>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 8.1CC: cfeist, cluster-maint, idevat, mlisik, omular, tojeline
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.10.4-1.el8 Doc Type: Bug Fix
Doc Text:
Cause: The corosync.conf file contains utf-8 characters. Consequence: Various pcs and pcsd commands and functionalities do not work. Fix: When reading the corosync.conf file, set its encoding to utf-8. Result: Pcs and pcsd works.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 15:27:56 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 Nina Hostakova 2019-08-15 13:41:47 UTC
Description of problem:
When changing quorum device parameters and using non-ASCII characters in values, the values are passed into corosync.conf, however pcsd is unable to process them.

Version-Release number of selected component (if applicable):
pcs-0.10.2-3.el8.x86_64

How reproducible:
always

Steps to Reproduce:
1. 
> Try to update qdevice using non-ASCII characters in a parameter's value, e.g. host
[root@virt-005 ~]# pcs quorum device update model host=virtč-004 algorithm=lms
Sending updated corosync.conf to nodes...
virt-005: Succeeded
virt-011: Succeeded
Warning: Error connecting to virt-005 (HTTP error: 500)
Warning: Error connecting to virt-011 (HTTP error: 500)
Error: Unable to perform operation on any available node/host, therefore it is not possible to continue
Error: Errors have occurred, therefore pcs is unable to continue

[root@virt-005 ~]# cat /etc/corosync/corosync.conf
...
quorum {
    provider: corosync_votequorum

    device {
        model: net

        net {
            algorithm: lms
            host: virtč-004
        }
    }
}
...

> This is also applicable to parameters with a predefined set of values to choose from, since the '--force' option can overwrite them
[root@virt-005 ~]# pcs quorum device update model host=virt-004 algorithm=lmsč --force
Warning: 'lmsč' is not a valid algorithm value, use 'ffsplit', 'lms'
Sending updated corosync.conf to nodes...
virt-005: Succeeded
virt-011: Succeeded
Warning: Error connecting to virt-005 (HTTP error: 500)
Warning: Error connecting to virt-011 (HTTP error: 500)
Error: Unable to perform operation on any available node/host, therefore it is not possible to continue
Error: Errors have occurred, therefore pcs is unable to continue

2. 
When trying to update the quorum device with an adjusted value (containing valid characters only), nodes are not able to be authenticated and pcsd does not communicate
[root@virt-005 ~]# pcs quorum device update model host=virt-004 algorithm=lms
Error: Hosts 'virt-005', 'virt-011' are not known to pcs, try to authenticate the hosts using 'pcs host auth virt-005 virt-011' command, use --skip-offline to override
Error: None of hosts is known to pcs.

[root@virt-005 ~]# pcs host auth virt-005 virt-011
Username: hacluster
Password: 
Error: Unable to communicate with pcsd

[root@virt-005 ~]# pcs quorum device update model host=virt-004 algorithm=lms --debug
...
--Debug Stderr Start--
/usr/lib/pcsd/corosyncconf.rb:115:in `split': invalid byte sequence in US-ASCII (ArgumentError)
	from /usr/lib/pcsd/corosyncconf.rb:115:in `parse_string'
	from /usr/lib/pcsd/pcs.rb:663:in `get_cluster_name'
	from /usr/lib/pcsd/pcsd-cli.rb:64:in `<main>'

--Debug Stderr End--
...


Actual results:
pcsd fails to proceed with corosync.conf containing non-ASCII characters. 
The characters then need to be manually removed from corosync.conf on all nodes

Expected results:
pcs should print out an error about non-valid characters or somehow handle them

Additional info:

Comment 2 Tomas Jelinek 2019-11-19 16:38:53 UTC
Created attachment 1637778 [details]
proposed fix

It turned out the presence of utf-8 characters in corosync.conf causes more issues than just an inability to edit corosync.conf via pcs as shown in comment 0. Some examples of what does not work:
* pcs host auth
* pcs cluster stop|start --all|<node>
* adding and removing cluster nodes
* config files syncing - exceptions are logged in pcsd log: WARNING -- : Config files sync exception: invalid byte sequence in US-ASCII

Comment 6 Miroslav Lisik 2019-11-29 08:54:32 UTC
Test:

[root@r81-node-01 pcs]# sed -i "s/ring0_addr: r81-node-02/ring0_addr: ř81-node-02/" /etc/corosync/corosync.conf
[root@r81-node-01 pcs]# grep ring0_addr /etc/corosync/corosync.conf
        ring0_addr: r81-node-01
        ring0_addr: ř81-node-02
[root@r81-node-01 pcs]# pcs host auth localhost
Username: hacluster
Password: 
localhost: Authorized
[root@r81-node-01 pcs]# echo $?
0
[root@r81-node-01 pcs]# pcs status pcsd localhost
  localhost: Online

Comment 10 errata-xmlrpc 2020-04-28 15:27:56 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/RHEA-2020:1568