From 798aa0545eb0dbd1adbf5eb49a8687d2821b6628 Mon Sep 17 00:00:00 2001 From: Thomas Rausch Date: Fri, 22 Sep 2023 18:05:49 +0200 Subject: [PATCH 1/2] use run_interactive for localstack ssh to fix tty issues --- localstack/cli/localstack.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/localstack/cli/localstack.py b/localstack/cli/localstack.py index 77d01b1d28b05..d23cf43abaf22 100644 --- a/localstack/cli/localstack.py +++ b/localstack/cli/localstack.py @@ -12,6 +12,7 @@ from localstack.utils.analytics.cli import publish_invocation from localstack.utils.bootstrap import get_container_default_logfile_location from localstack.utils.json import CustomEncoder +from localstack.utils.run import run_interactive from .console import BANNER, console from .plugin import LocalstackCli, load_cli_plugins @@ -617,15 +618,13 @@ def cmd_ssh() -> None: `MAIN_CONTAINER_NAME`. """ from localstack.utils.docker_utils import DOCKER_CLIENT - from localstack.utils.run import run if not DOCKER_CLIENT.is_container_running(config.MAIN_CONTAINER_NAME): raise CLIError( f'Expected a running LocalStack container named "{config.MAIN_CONTAINER_NAME}", but found none' ) try: - process = run("docker exec -it %s bash" % config.MAIN_CONTAINER_NAME, tty=True) - process.wait() + run_interactive(["docker", "exec", "-it", config.MAIN_CONTAINER_NAME, "bash"]) except KeyboardInterrupt: pass From 9713bfe244f273f9f86271b076dffe9e808256f2 Mon Sep 17 00:00:00 2001 From: Thomas Rausch Date: Fri, 22 Sep 2023 23:03:46 +0200 Subject: [PATCH 2/2] use os.execlp instead --- localstack/cli/localstack.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/localstack/cli/localstack.py b/localstack/cli/localstack.py index d23cf43abaf22..32fbbef76c6e1 100644 --- a/localstack/cli/localstack.py +++ b/localstack/cli/localstack.py @@ -12,7 +12,6 @@ from localstack.utils.analytics.cli import publish_invocation from localstack.utils.bootstrap import get_container_default_logfile_location from localstack.utils.json import CustomEncoder -from localstack.utils.run import run_interactive from .console import BANNER, console from .plugin import LocalstackCli, load_cli_plugins @@ -623,10 +622,7 @@ def cmd_ssh() -> None: raise CLIError( f'Expected a running LocalStack container named "{config.MAIN_CONTAINER_NAME}", but found none' ) - try: - run_interactive(["docker", "exec", "-it", config.MAIN_CONTAINER_NAME, "bash"]) - except KeyboardInterrupt: - pass + os.execlp("docker", "docker", "exec", "-it", config.MAIN_CONTAINER_NAME, "bash") @localstack.group(name="update", short_help="Update LocalStack")