From 8c263f48f19094cec0677a6a54527aa32a84b394 Mon Sep 17 00:00:00 2001 From: PawelPlesniak Date: Wed, 23 Oct 2024 19:49:57 +0200 Subject: [PATCH] Issue with throwing the correct error --- src/drunc/apps/__main_ssh_validator__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/drunc/apps/__main_ssh_validator__.py b/src/drunc/apps/__main_ssh_validator__.py index 4c385a8f..f309e874 100644 --- a/src/drunc/apps/__main_ssh_validator__.py +++ b/src/drunc/apps/__main_ssh_validator__.py @@ -23,9 +23,11 @@ def validate_config(confiuguration_filename:str, session_name:str): if segment_application not in session_dal.disabled: # If it is not disabled hosts.add(segment_application.runs_on.runs_on.id) + hosts.add("abc12") # case to throw, not throwing as expected ssh = Command('/usr/bin/ssh') runnning_tunnels = [] failed_hosts = [] + for host in hosts: user_host = f"{getpass.getuser()}@{host}" ssh_args = [user_host, "sleep 2s; exit;"] @@ -39,10 +41,11 @@ def validate_config(confiuguration_filename:str, session_name:str): _preexec_fn = on_parent_exit(signal.SIGTERM) if not macos else None ) ) - except Exception as e: - print(f"Failed to SSH onto host {user_host}, with error {str(e)}") + except sh.ErrorReturnCode_255: + print(f"Failed to SSH onto host {user_host}") failed_hosts.append(host) continue + for tunnel in runnning_tunnels: tunnel.wait(timeout=10)