Bug 1992938
| Summary: | SAP NW Plugin exception "IndexError: list index out of range" | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Rajesh Dulhani <rdulhani> | ||||
| Component: | sos | Assignee: | Pavel Moravec <pmoravec> | ||||
| Status: | CLOSED ERRATA | QA Contact: | Miroslav HradĂlek <mhradile> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 8.5 | CC: | agk, bmr, fkrska, jcastillo, jcastran, mhradile, mkluson, peter.vreman, plambri, pmoravec, sbradley, theute | ||||
| Target Milestone: | rc | Keywords: | Triaged | ||||
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
||||
| Hardware: | x86_64 | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | sos-4.3-1.el8 | Doc Type: | If docs needed, set a value | ||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2022-11-08 10:50:23 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
Rajesh Dulhani
2021-08-12 04:38:23 UTC
The fail occurs here: 38 sidsunique = set() 39 # Cycle through all the instances, get 'sid', 'instance_number' 40 # and 'vhost' to determine the proper profile 41 for inst_line in inst_out['output'].splitlines(): 42 if "DAA" not in inst_line: 43 fields = inst_line.strip().split() 44 sid = fields[3] 45 inst = fields[5] 46 vhost = fields[7] 47 sidsunique.add(sid) And we populate inst_line from inst_out['output'], which is gathered via the following command: 31 inst_out = self.collect_cmd_output( 32 "/usr/sap/hostctrl/exe/saphostctrl -function ListInstances", 33 suggest_filename="SAPInstances" 34 ) So what's the result of running: /usr/sap/hostctrl/exe/saphostctrl -function ListInstances Directly in this server after installing SAPHostAgent? ~~~ [Azure] vrempet-admin@li-lc-2622 ~ $ sudo /usr/sap/hostctrl/exe/saphostctrl -function ListInstances No instances found [Azure] vrempet-admin@li-lc-2622 ~ $ ~~~ Thank you for running the command Peter. I don't think we deal with this result in the plugin, be it the one reported here or the latest code upstream. I'm writing a quick patch to deal with this case - would you be able to test it? .. and the return code of that command is 0. We assumed that nonzero would be returned in that case, hence https://github.com/sosreport/sos/blob/legacy-3.9/sos/plugins/sapnw.py#L35-L36 will prevent continuation (and the traceback). I guess replacing line https://github.com/sosreport/sos/blob/legacy-3.9/sos/plugins/sapnw.py#L42 : if "DAA" not in inst_line: by: if "DAA" not in inst_line and not inst_line.startswith("No instances found"): will prevent the uncaught exception? (In reply to Pavel Moravec from comment #6) > I guess replacing line > https://github.com/sosreport/sos/blob/legacy-3.9/sos/plugins/sapnw.py#L42 : > > if "DAA" not in inst_line: > > by: > > if "DAA" not in inst_line and not inst_line.startswith("No > instances found"): > > will prevent the uncaught exception? Yes, I just tested it and it seems to work perfectly. The result captured is: # cat sosreport-localhost-2021-08-12-slaxlbr/sos_commands/sapnw/SAPInstances No instances found Confirming proposed patch works: ~~~ [Azure] vrempet-admin@li-lc-2622 ~ $ sudo /usr/sap/hostctrl/exe/saphostctrl -function ListInstances No instances found [Azure] vrempet-admin@li-lc-2622 ~ $ sudo sosreport -o sapnw --batch sosreport (version 3.9) This command will collect diagnostic and configuration information from this Red Hat Enterprise Linux system and installed applications. An archive containing the collected information will be generated in /var/tmp/sos.ivjXGk and may be provided to a Red Hat support representative. Any information provided to Red Hat will be treated in accordance with the published support policies at: https://access.redhat.com/support/ The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party. No changes will be made to system configuration. Setting up archive ... Setting up plugins ... caught exception in plugin method "sapnw.setup()" caught exception in plugin method "sapnw.setup()" writing traceback to sos_logs/sapnw-plugin-errors.txt writing traceback to sos_logs/sapnw-plugin-errors.txt Running plugins. Please wait ... Starting 1/1 sapnw [Running: sapnw] Finished running plugins Creating compressed archive... Your sosreport has been generated and saved in: /var/tmp/sosreport-li-lc-2622-2021-08-12-hoefbcd.tar.xz Size 1.82KiB Owner root md5 5434ff417c9e4d2e9f383c8d2943ec4b Please send this file to your support representative. [Azure] vrempet-admin@li-lc-2622 ~ $ sudo vi /usr/lib/python2.7/site-packages/sos/plugins/sapnw.py [Azure] vrempet-admin@li-lc-2622 ~ $ diff -u /usr/lib/python2.7/site-packages/sos/plugins/sapnw.py.210812-1 /usr/lib/python2.7/site-packages/sos/plugins/sapnw.py --- /usr/lib/python2.7/site-packages/sos/plugins/sapnw.py.210812-1 2021-06-16 07:51:00.000000000 +0000 +++ /usr/lib/python2.7/site-packages/sos/plugins/sapnw.py 2021-08-12 07:23:44.781100030 +0000 @@ -39,7 +39,7 @@ # Cycle through all the instances, get 'sid', 'instance_number' # and 'vhost' to determine the proper profile for inst_line in inst_out['output'].splitlines(): - if "DAA" not in inst_line: + if "DAA" not in inst_line and not inst_line.startswith("No instances found"): fields = inst_line.strip().split() sid = fields[3] inst = fields[5] [Azure] vrempet-admin@li-lc-2622 ~ $ [Azure] vrempet-admin@li-lc-2622 ~ $ sudo sosreport -o sapnw --batch sosreport (version 3.9) This command will collect diagnostic and configuration information from this Red Hat Enterprise Linux system and installed applications. An archive containing the collected information will be generated in /var/tmp/sos.yLNZet and may be provided to a Red Hat support representative. Any information provided to Red Hat will be treated in accordance with the published support policies at: https://access.redhat.com/support/ The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party. No changes will be made to system configuration. Setting up archive ... Setting up plugins ... Running plugins. Please wait ... Starting 1/1 sapnw [Running: sapnw] Finished running plugins Creating compressed archive... Your sosreport has been generated and saved in: /var/tmp/sosreport-li-lc-2622-2021-08-12-faprlin.tar.xz Size 1.67KiB Owner root md5 2d5ec31cd238e4897105261fab1c232b Please send this file to your support representative. ~~~ Safe code requires also that the outcome of 'fields = inst_line.strip().split()' is validated that the number of returned elements >=7 before you access the elements like 'fields[7]' (In reply to Peter Vreman from comment #9) > Safe code requires also that the outcome of 'fields = > inst_line.strip().split()' is validated that the number of returned elements > >=7 before you access the elements like 'fields[7]' Do you have an example of the output with no vhost? And what value of vhost is assumed if it doesn't appear in the output - localhost, or something similar? Jose, It was just normal code-review remark that the array indexing is done without a protection that enough elements are available. I have no real-world output available, but i am also not looking into the I have a real-world example where the output is an error, but that is gracefully handled by sosreport (older 3.7 version because it is RHEL7.7-E4S) ~~~ vrempet-admin@li-lc-1875 ~ $ sudo /usr/sap/hostctrl/exe/saphostctrl -function ListInstances Error: NIECONN_BROKEN (Connection reset by peer), NiRawRead failed in plugin_sapfrecv() vrempet-admin@li-lc-1875 ~ $ echo $? 1 vrempet-admin@li-lc-1875 ~ $ sudo sosreport -o sapnw --batch sosreport (version 3.7) This command will collect diagnostic and configuration information from this Red Hat Enterprise Linux system and installed applications. An archive containing the collected information will be generated in /var/tmp/sos.ATUw_D and may be provided to a Red Hat support representative. Any information provided to Red Hat will be treated in accordance with the published support policies at: https://access.redhat.com/support/ The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party. No changes will be made to system configuration. Setting up archive ... Setting up plugins ... Running plugins. Please wait ... Starting 1/1 sapnw [Running: sapnw] Finished running plugins ~~~ Peter I am in favour of improving the plugin robustness, if we are already changing it. Something like:
# Cycle through all the instances, get 'sid', 'instance_number'
# and 'vhost' to determine the proper profile
for inst_line in inst_out['output'].splitlines():
fields = inst_line.strip().split()
if "DAA" not in inst_line and not inst_line.startswith("No instances found") and len(fields)>6:
sid = fields[3]
inst = fields[5]
?
Pavel, I'm trying to get a machine in the lab to test this command, and how the output varies. Once I have it we can adjust more. As agreed internally, no RHEL7 backport is further needed and a fix in RHEL8 is sufficient. The main fix (https://github.com/sosreport/sos/pull/2643) will be released in RHEL8.6 and its robustness enhancement (https://github.com/sosreport/sos/pull/2647) will land in RHEL8.7. Reassigning the BZ to RHEL8. Hello, as our QE might not have available systems for testing the fix, would you be able to verify the fix once available (as a candidate package for 8.7)? How to test this: mock /usr/sap/hostctrl/exe/saphostctrl to *either* (test both options) - print "No instances found" and return nonzero (#2643) - print a line with less than 7 words (i.e. the same) and return zero (#2647) (In reply to Pavel Moravec from comment #22) > How to test this: > > mock /usr/sap/hostctrl/exe/saphostctrl to *either* (test both options) > > - print "No instances found" and return nonzero (#2643) > - print a line with less than 7 words (i.e. the same) and return zero (#2647) Oh wrong description as nonzero return code means nothing to collect. Proper tests: mock /usr/sap/hostctrl/exe/saphostctrl to return 0 and *either* (test both options) - print "No instances found" (#2643) - print a line with other text having less than 7 words (#2647) 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 (sos 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:7732 The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days |