Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: scripts: Filter out unreachable nodes in cluster health #1570

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions crmsh/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,10 +1257,17 @@
nodes = nodes.replace(',', ' ').split()
else:
nodes = utils.list_cluster_nodes()
if not nodes:
raise ValueError("No hosts")
nodes = [(node, port or None, user or None) for node in nodes]
return nodes

reachable_nodes = []
for node in nodes:
try:
utils.node_reachable_check(node)
reachable_nodes.append((node, port or None, user or None))
except ValueError:
logger.warning("Node %s is unreachable", node)

Check warning on line 1267 in crmsh/scripts.py

View check run for this annotation

Codecov / codecov/patch

crmsh/scripts.py#L1266-L1267

Added lines #L1266 - L1267 were not covered by tests
if not reachable_nodes:
raise ValueError("No reachable hosts")

Check warning on line 1269 in crmsh/scripts.py

View check run for this annotation

Codecov / codecov/patch

crmsh/scripts.py#L1269

Added line #L1269 was not covered by tests
return reachable_nodes


def _scoped_param(context, name):
Expand Down
2 changes: 2 additions & 0 deletions crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2471,6 +2471,8 @@ def node_reachable_check(node, ping_count=1, port=22, timeout=3):
"""
Check if node is reachable by using ping and socket to ssh port
"""
if options.regression_tests:
return True
rc, _, _ = ShellUtils().get_stdout_stderr(f"ping -n -c {ping_count} -W {timeout} {node}")
if rc == 0:
return True
Expand Down