Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1687954 - Index out of range in the buildah plugin, due to scratch container without an id.
Summary: Index out of range in the buildah plugin, due to scratch container without an...
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: sos
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: 8.0
Assignee: Pavel Moravec
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-12 18:22 UTC by Ryan Blakley
Modified: 2019-04-15 09:57 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github sosreport sos pull 1647 None None None 2019-04-15 09:57:14 UTC

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


Note You need to log in before you can comment on or make changes to this bug.