diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2022-11-21 10:30:32 -0500 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2022-11-21 14:19:17 -0500 |
commit | 08679ccb240ae2b269d92302eaf4401dba5673e9 (patch) | |
tree | eca4a71c0c8ffa7862ad0ee3adcb6d4babd01904 | |
parent | f596b912b3c52b3e101a880fdd1720df2412f4e1 (diff) | |
download | sos-08679ccb240ae2b269d92302eaf4401dba5673e9.tar.gz |
[collector] Handle potential edge case exception in node list enumeration
Adds handling to catch the condition where we get something other than a
string or list from `get_nodes()` to `format_node_list()`.
Related: #3066
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | sos/collector/clusters/__init__.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sos/collector/clusters/__init__.py b/sos/collector/clusters/__init__.py index f00677b8..7356e153 100644 --- a/sos/collector/clusters/__init__.py +++ b/sos/collector/clusters/__init__.py @@ -392,13 +392,14 @@ class Cluster(): """ try: nodes = self.get_nodes() - except Exception as e: - self.log_error('Cluster failed to enumerate nodes: %s' % e) - raise + except Exception as err: + raise Exception(f"Cluster failed to enumerate nodes: {err}") if isinstance(nodes, list): node_list = [n.strip() for n in nodes if n] elif isinstance(nodes, str): node_list = [n.split(',').strip() for n in nodes] + else: + raise Exception(f"Cluster returned unexpected node list: {nodes}") node_list = list(set(node_list)) for node in node_list: if node.startswith(('-', '_', '(', ')', '[', ']', '/', '\\')): |