Bug 2102292

Summary: stonith_admin --validate seems to be broken
Product: Red Hat Enterprise Linux 9 Reporter: Tomas Jelinek <tojeline>
Component: pacemakerAssignee: Chris Lumens <clumens>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: urgent    
Version: 9.0CC: cluster-maint, jrehova, kgaillot, mjuricek, msmazova, nwahl, toneata
Target Milestone: rcKeywords: Regression, Triaged
Target Release: 9.1   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: pacemaker-2.1.4-3.el9 Doc Type: No Doc Update
Doc Text:
There currently is no pcs interface to the affected command, and the average user will never see it
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 09:49:38 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:
Bug Depends On:    
Bug Blocks: 1553712, 1816852, 2112270, 2112271    

Description Tomas Jelinek 2022-06-29 15:18:20 UTC
Description of problem:
Running `stonith_admin --validate` doesn't seem to properly process and pass data from fence agents. Based on bz1434936 comment 23, stonith_admin is expected to return the same results as:
echo -e "action=validate-all\nport=node1\n<param>=<value>\n<param>=<value>\n<etc.>" | fence_<whatever>
That doesn't seem to be happening.


Version-Release number of selected component (if applicable):
pacemaker-2.1.4-1.el9.x86_64


How reproducible:
always, easily


Steps to Reproduce:
> run a fence agent directly in such a way that validation fails:
# echo -e "action=validate-all\nport=node1" | fence_apc
2022-06-29 17:10:52,108 ERROR: Failed: You have to set login name

2022-06-29 17:10:52,109 ERROR: Failed: You have to enter fence address

2022-06-29 17:10:52,109 ERROR: Failed: You have to enter password, password script or identity file

2022-06-29 17:10:52,109 ERROR: validate-all failed

2022-06-29 17:10:52,109 ERROR: Please use '-h' for usage
# echo $?
1

> run a fence agent via stonith_admin in such a way that validation fails:
# stonith_admin --output-as=xml --validate --agent fence_apc
<pacemaker-result api-version="2.20" request="stonith_admin --output-as=xml --validate --agent fence_apc">
  <validate agent="fence_apc" valid="true">
    <command code="-103"/>
  </validate>
  <status code="102" message="Not connected"/>
</pacemaker-result>
# echo $?
102

issues:
* actual: valid="true", expected: valid="false"
* actual: messages from the fence agent are not present in stonith_admin output, expected: messages from the fence agent are present in stonith_admin output



> run a fence agent directly in such a way that validation passes:
# echo -e "action=validate-all\nport=node1\nusername=apc\npasswd=apc\nip=192.168.122.254" | fence_apc
# echo $?
0

> run a fence agent via stonith_admin in such a way that validation passes:
# stonith_admin --output-as=xml  --validate --agent fence_apc --option username=apc --option passwd=apc --option ip=192.168.122.254
<pacemaker-result api-version="2.20" request="stonith_admin --output-as=xml --validate --agent fence_apc --option username=apc --option passwd=apc --option ip=192.168.122.254">
  <validate agent="fence_apc" valid="false">
    <command code="0"/>
  </validate>
  <status code="0" message="OK"/>
</pacemaker-result>
# echo $?
0

issues:
* actual: valid="false", expected: valid="true"

Comment 1 Tomas Jelinek 2022-06-29 15:32:42 UTC
This is working as I expect in pacemaker 2.0:

# stonith_admin --output-as=xml --validate --agent fence_apc
<pacemaker-result api-version="2.2" request="stonith_admin --output-as=xml --validate --agent fence_apc">
  <validate agent="fence_apc" valid="false">
    <command code="-201">
      <output source="stderr">2022-06-29 17:29:05,499 ERROR: Failed: You have to set login name

2022-06-29 17:29:05,500 ERROR: Failed: You have to enter fence address

2022-06-29 17:29:05,500 ERROR: Failed: You have to enter password, password script or identity file

2022-06-29 17:29:05,500 ERROR: validate-all failed

2022-06-29 17:29:05,500 ERROR: Please use '-h' for usage

</output>
    </command>
  </validate>
  <status code="1" message="Error occurred"/>
</pacemaker-result>
# echo $?
1
# rpm -q pacemaker
pacemaker-2.0.4-6.el8.x86_64

Comment 2 Ken Gaillot 2022-06-29 19:44:56 UTC
At least the first issue here is a regression: Since commit 91a2b2e417 in the Pacemaker 2.0.5 release (RHEL 8.4), the sense of "valid" in the XML output was accidentally flipped. I.e. the XML output has valid="true" if the options are invalid and valid="false" if they are valid :-/

Pacemaker currently doesn't have regression tests for stonith_admin --validate, so that obviously needs to be added.

The second issue (regarding the error messages) requires more investigation.

Comment 6 Reid Wahl 2022-06-30 00:12:25 UTC
The "not connected" issue began with this commit:
  - Low: libcrmservice: always set rc/status when executing files (https://github.com/ClusterLabs/pacemaker/pull/2512/commits/b441925e2da6b938db0674b98783d1dfb3d2a096)

Comment 12 Ken Gaillot 2022-07-21 20:47:49 UTC
The fix was merged in the upstream main branch as of commit 81e83683

Bumping the DTM one week. The build is actually done but there is an unrelated issue affecting gating with a fix working its way through the system

Comment 13 Ken Gaillot 2022-07-28 23:01:19 UTC
Bumping the DTM another week. The gating fix is done but all the jobs haven't been rerun yet. :-/ If it's not done by early next week I may waive that test.

Comment 20 jrehova 2022-08-24 14:20:14 UTC
Version of pacemaker:

> [root@node_01 ~]# rpm -q pacemaker
> pacemaker-2.1.4-5.el9.x86_64

Run a fence agent directly in such a way that validation fails:

> [root@node_01 ~]# echo -e "action=validate-all\nport=node1" | fence_apc
> 2022-08-24 09:02:25,407 ERROR: Failed: You have to set login name
> 
> 2022-08-24 09:02:25,407 ERROR: Failed: You have to enter fence address
> 
> 2022-08-24 09:02:25,408 ERROR: Failed: You have to enter password, password script or identity file
> 
> 2022-08-24 09:02:25,408 ERROR: validate-all failed
> 
> 2022-08-24 09:02:25,408 ERROR: Please use '-h' for usage
 
> [root@node_01 ~]# echo $?
> 1

Run a fence agent via stonith_admin in such a way that validation fails:

> [root@node_01 ~]# stonith_admin --output-as=xml --validate --agent fence_apc
> <pacemaker-result api-version="2.22" request="stonith_admin --output-as=xml --validate --agent fence_apc">
>   <validate agent="fence_apc" valid="false">
>     <command code="-201">
>       <output source="stderr">2022-08-24 09:03:44,867 ERROR: Failed: You have to set login name
> 
> 2022-08-24 09:03:44,867 ERROR: Failed: You have to enter fence address
> 
> 2022-08-24 09:03:44,867 ERROR: Failed: You have to enter password, password script or identity file
> 
> 2022-08-24 09:03:44,868 ERROR: validate-all failed
> 
> 2022-08-24 09:03:44,868 ERROR: Please use '-h' for usage
> 
> </output>
>     </command>
>   </validate>
>   <status code="1" message="Error occurred"/>
> </pacemaker-result>
 
> [root@node_01 ~]# echo $?
> 1

Run a fence agent directly in such a way that validation passes:

> [root@node_01 ~]# echo -e "action=validate-all\nport=node1\nusername=abc\npasswd=abc\nip=192.168.122.254" | fence_apc
 
> [root@node_01 ~]# echo $?
> 0

Run a fence agent via stonith_admin in such a way that validation passes:

> [root@node_01 ~]# stonith_admin --output-as=xml  --validate --agent fence_apc --option username=abc --option passwd=abc --option ip=192.168.122.254
> <pacemaker-result api-version="2.22" request="stonith_admin --output-as=xml --validate --agent fence_apc --option username=abc --option passwd=abc --option ip=192.168.122.254">
>   <validate agent="fence_apc" valid="true">
>     <command code="0"/>
>   </validate>
>   <status code="0" message="OK"/>
> </pacemaker-result>
 
> [root@node_01 ~]# echo $?
> 0

Comment 22 errata-xmlrpc 2022-11-15 09:49:38 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:7937