Bug 2136477

Summary: XML output of crm_verify doesn't contain error messages
Product: Red Hat Enterprise Linux 9 Reporter: Tomas Jelinek <tojeline>
Component: pacemakerAssignee: gchin
Status: CLOSED MIGRATED QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: medium    
Version: 9.0CC: cluster-maint
Target Milestone: rcKeywords: FutureFeature, MigratedToJIRA, Triaged
Target Release: 9.4Flags: pm-rhel: mirror+
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Feature: crm_verify's XML output now includes any schema validation errors. Reason: The previous output, which contained only the final valid or invalid status, did not give enough detail to be usable. Result: Scripts that parse crm_verify's XML output can now use any schema validation error messages.
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-22 19:51:05 UTC Type: Story
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: 2136483    

Description Tomas Jelinek 2022-10-20 11:41:22 UTC
Description of problem:
XML output of crm_verify doesn't contain error messages, they only go to stderr as a plaintext. This makes the XML output pretty much useless.


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


How reproducible:
always, easily


Steps to Reproduce:
1. create an invalid configuration, e.g. pcs resource create test1 systemd:chronyd promotable
2. run crm_verify output-as=xml


Actual results:
# crm_verify --live-check --output-as=xml -VV
(native_unpack)         error: Resource test1:0 is of type systemd and therefore cannot be used as a promotable clone resource
(pe__create_clone_child)        error: Failed unpacking resource test1
(unpack_resources)      error: Ignoring <clone> resource 'test1-clone' because configuration is invalid
crm_verify: Errors found during check: config not valid
<pacemaker-result api-version="2.22" request="crm_verify --live-check --output-as=xml -VV">
  <status code="78" message="Invalid configuration"/>
</pacemaker-result>


Expected results:
# crm_verify --live-check --output-as=xml
<pacemaker-result api-version="2.22" request="crm_verify --live-check --output-as=xml">
  <status code="78" message="Invalid configuration"/>
  <messages>
    <message severity="error" code="native_unpack">
      Resource test1:0 is of type systemd and therefore cannot be used as a promotable clone resource
    </message>
    <message severity="error" code="pe__create_clone_child">
      Failed unpacking resource test1
    </message>
    <message severity="error" code="unpack_resources">
      Ignoring &lt;clone&gt; resource 'test1-clone' because configuration is invalid
    </message>
  </messages>
</pacemaker-result>

Names of the tags and attributes are not as important as the structure: separate code, severity and message text.
Also, since XML is easy to parse and filter, consider including errors and warnings by default. For plaintext output, crm_verify requires -V to be specified to print them.

Please, avoid splitting one item over several lines / messages like in the following example:
# crm_verify --live-check --output-as=xml -VV
(unpack_resources)      error: Resource start-up disabled since no STONITH resources have been defined
(unpack_resources)      error: Either configure some or disable STONITH with the stonith-enabled option
(unpack_resources)      error: NOTE: Clusters with shared data need STONITH to ensure data integrity
crm_verify: Errors found during check: config not valid


Additional info:
We are planning to run crm_verify from 'pcs status' command and include errors and warnings in the output. This will allow us to provide more error messages which will be more accurate than what pcs provides now with its clunky checks. We are also considering running crm_verify whenever a user makes any changes to CIB. Let us know if these are bad ideas. We'd also appreciate info about corner-cases we may hit, if you know any. Thanks!

Comment 2 RHEL Program Management 2023-09-22 19:49:21 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 3 RHEL Program Management 2023-09-22 19:51:05 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.