|
|
003633 |
From 137abd394f64a63b6633949b5c81159af12038b7 Mon Sep 17 00:00:00 2001
|
|
|
003633 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
003633 |
Date: Fri, 14 Jan 2022 20:07:17 +0100
|
|
|
003633 |
Subject: [PATCH] [report] pass foreground argument to collect_cmd_output
|
|
|
003633 |
|
|
|
003633 |
Related to: #2825
|
|
|
003633 |
|
|
|
003633 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
003633 |
---
|
|
|
003633 |
sos/report/plugins/__init__.py | 12 +++++++++---
|
|
|
003633 |
1 file changed, 9 insertions(+), 3 deletions(-)
|
|
|
003633 |
|
|
|
003633 |
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
|
|
|
003633 |
index 98f163ab9..1bbdf28a4 100644
|
|
|
003633 |
--- a/sos/report/plugins/__init__.py
|
|
|
003633 |
+++ b/sos/report/plugins/__init__.py
|
|
|
003633 |
@@ -1920,6 +1920,8 @@ class Plugin(object):
|
|
|
003633 |
:param subdir: Subdir in plugin directory to save to
|
|
|
003633 |
:param changes: Does this cmd potentially make a change
|
|
|
003633 |
on the system?
|
|
|
003633 |
+ :param foreground: Run the `cmd` in the foreground with a
|
|
|
003633 |
+ TTY
|
|
|
003633 |
:param tags: Add tags in the archive manifest
|
|
|
003633 |
:param cmd_as_tag: Format command string to tag
|
|
|
003633 |
|
|
|
003633 |
@@ -2145,7 +2147,8 @@ def collect_cmd_output(self, cmd, suggest_filename=None,
|
|
|
003633 |
root_symlink=False, timeout=None,
|
|
|
003633 |
stderr=True, chroot=True, runat=None, env=None,
|
|
|
003633 |
binary=False, sizelimit=None, pred=None,
|
|
|
003633 |
- changes=False, subdir=None, tags=[]):
|
|
|
003633 |
+ changes=False, foreground=False, subdir=None,
|
|
|
003633 |
+ tags=[]):
|
|
|
003633 |
"""Execute a command and save the output to a file for inclusion in the
|
|
|
003633 |
report, then return the results for further use by the plugin
|
|
|
003633 |
|
|
|
003633 |
@@ -2188,6 +2191,9 @@ def collect_cmd_output(self, cmd, suggest_filename=None,
|
|
|
003633 |
on the system?
|
|
|
003633 |
:type changes: ``bool``
|
|
|
003633 |
|
|
|
003633 |
+ :param foreground: Run the `cmd` in the foreground with a TTY
|
|
|
003633 |
+ :type foreground: ``bool``
|
|
|
003633 |
+
|
|
|
003633 |
:param tags: Add tags in the archive manifest
|
|
|
003633 |
:type tags: ``str`` or a ``list`` of strings
|
|
|
003633 |
|
|
|
003633 |
@@ -2206,8 +2212,8 @@ def collect_cmd_output(self, cmd, suggest_filename=None,
|
|
|
003633 |
return self._collect_cmd_output(
|
|
|
003633 |
cmd, suggest_filename=suggest_filename, root_symlink=root_symlink,
|
|
|
003633 |
timeout=timeout, stderr=stderr, chroot=chroot, runat=runat,
|
|
|
003633 |
- env=env, binary=binary, sizelimit=sizelimit, subdir=subdir,
|
|
|
003633 |
- tags=tags
|
|
|
003633 |
+ env=env, binary=binary, sizelimit=sizelimit, foreground=foreground,
|
|
|
003633 |
+ subdir=subdir, tags=tags
|
|
|
003633 |
)
|
|
|
003633 |
|
|
|
003633 |
def exec_cmd(self, cmd, timeout=None, stderr=True, chroot=True,
|
|
|
003633 |
From 747fef695e4ff08f320c5f03090bdefa7154c761 Mon Sep 17 00:00:00 2001
|
|
|
003633 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
003633 |
Date: Fri, 14 Jan 2022 20:10:22 +0100
|
|
|
003633 |
Subject: [PATCH] [virsh] Call virsh commands in the foreground / with a TTY
|
|
|
003633 |
|
|
|
003633 |
In some virsh errors (like unable to connect to a hypervisor),
|
|
|
003633 |
the tool requires to communicate to TTY otherwise it can get stuck
|
|
|
003633 |
(when called via Popen with a timeout).
|
|
|
003633 |
|
|
|
003633 |
Calling it on foreground prevents the stuck / waiting on cmd timeout.
|
|
|
003633 |
|
|
|
003633 |
Resolves: #2825
|
|
|
003633 |
|
|
|
003633 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
003633 |
---
|
|
|
003633 |
sos/report/plugins/virsh.py | 14 +++++++++-----
|
|
|
003633 |
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
|
003633 |
|
|
|
003633 |
diff --git a/sos/report/plugins/virsh.py b/sos/report/plugins/virsh.py
|
|
|
003633 |
index d6b7c16761..08f9a8488c 100644
|
|
|
003633 |
--- a/sos/report/plugins/virsh.py
|
|
|
003633 |
+++ b/sos/report/plugins/virsh.py
|
|
|
003633 |
@@ -39,26 +39,30 @@ def setup(self):
|
|
|
003633 |
]
|
|
|
003633 |
|
|
|
003633 |
for subcmd in subcmds:
|
|
|
003633 |
- self.add_cmd_output('%s %s' % (cmd, subcmd))
|
|
|
003633 |
+ self.add_cmd_output('%s %s' % (cmd, subcmd), foreground=True)
|
|
|
003633 |
|
|
|
003633 |
# get network, pool and nwfilter elements
|
|
|
003633 |
for k in ['net', 'nwfilter', 'pool']:
|
|
|
003633 |
- k_list = self.collect_cmd_output('%s %s-list' % (cmd, k))
|
|
|
003633 |
+ k_list = self.collect_cmd_output('%s %s-list' % (cmd, k),
|
|
|
003633 |
+ foreground=True)
|
|
|
003633 |
if k_list['status'] == 0:
|
|
|
003633 |
k_lines = k_list['output'].splitlines()
|
|
|
003633 |
# the 'Name' column position changes between virsh cmds
|
|
|
003633 |
pos = k_lines[0].split().index('Name')
|
|
|
003633 |
for j in filter(lambda x: x, k_lines[2:]):
|
|
|
003633 |
n = j.split()[pos]
|
|
|
003633 |
- self.add_cmd_output('%s %s-dumpxml %s' % (cmd, k, n))
|
|
|
003633 |
+ self.add_cmd_output('%s %s-dumpxml %s' % (cmd, k, n),
|
|
|
003633 |
+ foreground=True)
|
|
|
003633 |
|
|
|
003633 |
# cycle through the VMs/domains list, ignore 2 header lines and latest
|
|
|
003633 |
# empty line, and dumpxml domain name in 2nd column
|
|
|
003633 |
- domains_output = self.exec_cmd('%s list --all' % cmd)
|
|
|
003633 |
+ domains_output = self.exec_cmd('%s list --all' % cmd, foreground=True)
|
|
|
003633 |
if domains_output['status'] == 0:
|
|
|
003633 |
domains_lines = domains_output['output'].splitlines()[2:]
|
|
|
003633 |
for domain in filter(lambda x: x, domains_lines):
|
|
|
003633 |
d = domain.split()[1]
|
|
|
003633 |
for x in ['dumpxml', 'dominfo', 'domblklist']:
|
|
|
003633 |
- self.add_cmd_output('%s %s %s' % (cmd, x, d))
|
|
|
003633 |
+ self.add_cmd_output('%s %s %s' % (cmd, x, d),
|
|
|
003633 |
+ foreground=True)
|
|
|
003633 |
+
|
|
|
003633 |
# vim: et ts=4 sw=4
|
|
|
003633 |
From 9bc032129ec66766f07349dd115335f104888efa Mon Sep 17 00:00:00 2001
|
|
|
003633 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
003633 |
Date: Wed, 26 Jan 2022 09:44:01 +0100
|
|
|
003633 |
Subject: [PATCH] [virsh] Catch parsing exception
|
|
|
003633 |
|
|
|
003633 |
In case virsh output is malformed or missing 'Name' otherwise,
|
|
|
003633 |
catch parsing exception and continue in next for loop iteration.
|
|
|
003633 |
|
|
|
003633 |
Resolves: #2836
|
|
|
003633 |
|
|
|
003633 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
003633 |
---
|
|
|
003633 |
sos/report/plugins/virsh.py | 6 +++++-
|
|
|
003633 |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
003633 |
|
|
|
003633 |
diff --git a/sos/report/plugins/virsh.py b/sos/report/plugins/virsh.py
|
|
|
003633 |
index 08f9a8488..2ce1df15c 100644
|
|
|
003633 |
--- a/sos/report/plugins/virsh.py
|
|
|
003633 |
+++ b/sos/report/plugins/virsh.py
|
|
|
003633 |
@@ -48,7 +48,11 @@ def setup(self):
|
|
|
003633 |
if k_list['status'] == 0:
|
|
|
003633 |
k_lines = k_list['output'].splitlines()
|
|
|
003633 |
# the 'Name' column position changes between virsh cmds
|
|
|
003633 |
- pos = k_lines[0].split().index('Name')
|
|
|
003633 |
+ # catch the rare exceptions when 'Name' is not found
|
|
|
003633 |
+ try:
|
|
|
003633 |
+ pos = k_lines[0].split().index('Name')
|
|
|
003633 |
+ except Exception:
|
|
|
003633 |
+ continue
|
|
|
003633 |
for j in filter(lambda x: x, k_lines[2:]):
|
|
|
003633 |
n = j.split()[pos]
|
|
|
003633 |
self.add_cmd_output('%s %s-dumpxml %s' % (cmd, k, n),
|