aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2019-02-25 15:38:45 -0500
committerBryn M. Reeves <bmr@redhat.com>2019-03-21 12:25:39 +0000
commitad02774656fbe04cb8ddbb25bdfb68fbe2aa19d8 (patch)
tree15a061d7c513bbad9ec1ecb2191fc07b7593d260
parent080c2de9dd79c6d32aa07f3cd0c45204c4ede7b6 (diff)
downloadsos-ad02774656fbe04cb8ddbb25bdfb68fbe2aa19d8.tar.gz
[podman] Correct command collection, add volume info collection
Updates the podman plugin to collect volume information such as 'volume ls' and 'volume inspect' for every reported volume. Additionally, corrects the inspect iteration to not potentially call 'podman logs' on image IDs, only container IDs. The image inspect commands will also now use the image name unless either the name or tage includes 'none', in which case the image ID is used. Removes the attempt to collect a podman journal - podman does not log to a journal unit. Finally adds '--all' to the stats command, as podman requires this option when not specifying specific containers. Resolves: #1579 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/podman.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/sos/plugins/podman.py b/sos/plugins/podman.py
index 80c1878b..27a8eb1a 100644
--- a/sos/plugins/podman.py
+++ b/sos/plugins/podman.py
@@ -44,8 +44,9 @@ class Podman(Plugin, RedHatPlugin, UbuntuPlugin):
'port --all',
'ps',
'ps -a',
- 'stats --no-stream',
+ 'stats --no-stream --all',
'version',
+ 'volume ls'
]
self.add_cmd_output(["podman %s" % s for s in subcmds])
@@ -54,26 +55,42 @@ class Podman(Plugin, RedHatPlugin, UbuntuPlugin):
if self.get_option('size'):
self.add_cmd_output('podman ps -as')
- self.add_journal(units="podman")
self.add_cmd_output("ls -alhR /etc/cni")
ps_cmd = 'podman ps -q'
if self.get_option('all'):
ps_cmd = "%s -a" % ps_cmd
- img_cmd = 'podman images -q'
- insp = set()
+ fmt = '{{lower .Repository}}:{{lower .Tag}} {{lower .ID}}'
+ img_cmd = "podman images --format='%s'" % fmt
+ vol_cmd = 'podman volume ls -q'
- for icmd in [ps_cmd, img_cmd]:
- result = self.get_command_output(icmd)
- if result['status'] == 0:
- for con in result['output'].splitlines():
- insp.add(con)
+ containers = self._get_podman_list(ps_cmd)
+ images = self._get_podman_list(img_cmd)
+ volumes = self._get_podman_list(vol_cmd)
- for container in insp:
+ for container in containers:
self.add_cmd_output("podman inspect %s" % container)
- if self.get_option('logs'):
- self.add_cmd_output("podman logs -t %s" % container)
+
+ for img in images:
+ name, img_id = img.strip().split()
+ insp = name if 'none' not in name else img_id
+ self.add_cmd_output("podman inspect %s" % insp)
+
+ for vol in volumes:
+ self.add_cmd_output("podman volume inspect %s" % vol)
+
+ if self.get_option('logs'):
+ for con in containers:
+ self.add_cmd_output("podman logs -t %s" % con)
+
+ def _get_podman_list(self, cmd):
+ ret = []
+ result = self.get_command_output(cmd)
+ if result['status'] == 0:
+ for ent in result['output'].splitlines():
+ ret.append(ent)
+ return ret
def postproc(self):
# Attempts to match key=value pairs inside container inspect output