Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1687954

Summary: Index out of range in the buildah plugin, due to scratch container without an id.
Product: Red Hat Enterprise Linux 8 Reporter: Ryan Blakley <rblakley>
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Miroslav HradĂ­lek <mhradile>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.0CC: agk, bmr, dornelas, gavin, jhunsaker, plambri, sbradley
Target Milestone: rcKeywords: OtherQA
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sos-3.7-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-05 22:32:24 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: 1186913    

Description Ryan Blakley 2019-03-12 18:22:35 UTC
Description of problem: 
Index out of range in the buildah plugin, when there is a scratch built container.


Version-Release number of selected component (if applicable): 
sos-3.6-10.el8.noarch


Steps to Reproduce:
1. Run # buildah from scratch to create a scratch container.
2. Run # sosreport -o buildah


Actual results:
# cat sos_logs/buildah-plugin-errors.txt 
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/sos/sosreport.py", line 1031, in setup
    plug.setup()
  File "/usr/lib/python3.6/site-packages/sos/plugins/buildah.py", line 39, in setup
    brady = containah.split()[4]
IndexError: list index out of range

# cat sos_commands/buildah/buildah_containers 
CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
e01b4c5a0d1c     *     a80dad1c1953 registry.redhat.io/rhel8-beta/rhel:latest rhel-working-container
7183139a0f71     *                  scratch                          working-container <<<---doesn't have an image id.


Additional info: 
The below patch should fix the issue, since it will always be the last item in the array we can use -1 instead of determining the len and subtracting one. I tested with the below change, and it works perfect afterwards.

root@ryan-rhel8 ~ # diff -up /usr/lib/python3.6/site-packages/sos/plugins/buildah.py.old /usr/lib/python3.6/site-packages/sos/plugins/buildah.py
--- /usr/lib/python3.6/site-packages/sos/plugins/buildah.py.old	2019-03-12 12:41:21.364784851 -0400
+++ /usr/lib/python3.6/site-packages/sos/plugins/buildah.py	2019-03-12 12:41:30.208072777 -0400
@@ -36,7 +36,7 @@ class Buildah(Plugin, RedHatPlugin):
         if containahs['is_wicked_pissah']:
             for containah in containahs['auutput'].splitlines():
                 # obligatory Tom Brady
-                brady = containah.split()[4]
+                brady = containah.split()[-1]
                 self.add_cmd_output('buildah inspect -t container %s' % brady)
 
         pitchez = make_chowdah('buildah images -n')

Comment 1 Pavel Moravec 2019-03-18 09:20:30 UTC
There is no need to collect buildah info about scratch containers? As we can also call there:

brady = containah.split()[0]

to identify the container by its ID. This will imho work also for scratch containers, but sosreport will name files with collected output like

buildad_inspect_-t_container_e01b4c5a0d1c

instead of having the container name there.

Some preference between [0] and [-1] ?

Comment 2 Ryan Blakley 2019-03-18 13:21:06 UTC
(In reply to Pavel Moravec from comment #1)
> There is no need to collect buildah info about scratch containers? As we can
> also call there:
> 
> brady = containah.split()[0]
> 
> to identify the container by its ID. This will imho work also for scratch
> containers, but sosreport will name files with collected output like
> 
> buildad_inspect_-t_container_e01b4c5a0d1c
> 
> instead of having the container name there.
> 
> Some preference between [0] and [-1] ?

That's a good point the id would probably be better than the name since it will be unique. I also reached out to a container engineer to ask for their preference, and he confirmed the id would be better as well.

Comment 3 Jake Hunsaker 2019-03-22 18:53:32 UTC
As a FL sbr-containers engineer, I disagree that the ID is better here.

We recently changed the docker and podman plugins to both use image names for '$thing inspect <image>' to visually differentiate them from '$thing inspect <container>' for suppoer engineers. In the buildah plugin we're already doing that, so I don't think we should change to not using names when we don't have to, since buildah already prevents duplicate-named containers.

Using .split()[-1] is a better fix in my opinion.

Comment 4 Pavel Moravec 2019-04-15 09:57:14 UTC
devel_ack+ for 8.1

Comment 6 Pavel Moravec 2019-06-12 14:43:30 UTC
Jake H. agreed to do OtherQE (thanks!).

Comment 8 Pavel Moravec 2019-06-13 09:09:55 UTC
Jake,
could you pls. verify the BZ against below build? Thanks in advance.


A yum repository for the build of sos-3.7-1.el8 (task 22133742) is available at:

http://brew-task-repos.usersys.redhat.com/repos/official/sos/3.7/1.el8/

You can install the rpms locally by putting this .repo file in your /etc/yum.repos.d/ directory:

http://brew-task-repos.usersys.redhat.com/repos/official/sos/3.7/1.el8/sos-3.7-1.el8.repo

RPMs and build logs can be found in the following locations:
http://brew-task-repos.usersys.redhat.com/repos/official/sos/3.7/1.el8/noarch/

The full list of available rpms is:
http://brew-task-repos.usersys.redhat.com/repos/official/sos/3.7/1.el8/noarch/sos-3.7-1.el8.src.rpm
http://brew-task-repos.usersys.redhat.com/repos/official/sos/3.7/1.el8/noarch/sos-audit-3.7-1.el8.noarch.rpm
http://brew-task-repos.usersys.redhat.com/repos/official/sos/3.7/1.el8/noarch/sos-3.7-1.el8.noarch.rpm

Build output will be available for the next 21 days.

Comment 10 Jake Hunsaker 2019-06-20 18:37:10 UTC
Verified that sos-3.7-1 captures scratch container information correctly now and no error is thrown in plugin execution.

Comment 13 errata-xmlrpc 2019-11-05 22:32:24 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-2019:3640