From 1b8c7e062c7e2b7083db4c1360600adf8ff5c2a1 Mon Sep 17 00:00:00 2001 From: Silas Strawn Date: Thu, 5 May 2022 11:32:32 -0700 Subject: [PATCH] add timeout to container app ping for ssh/logstream --- src/containerapp/azext_containerapp/_ssh_utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/containerapp/azext_containerapp/_ssh_utils.py b/src/containerapp/azext_containerapp/_ssh_utils.py index a6c3b17a691..c37ad199f75 100644 --- a/src/containerapp/azext_containerapp/_ssh_utils.py +++ b/src/containerapp/azext_containerapp/_ssh_utils.py @@ -160,9 +160,12 @@ def _getch_windows(): def ping_container_app(app): site = safe_get(app, "properties", "configuration", "ingress", "fqdn") if site: - resp = requests.get(f'https://{site}') - if not resp.ok: - logger.info(f"Got bad status pinging app: {resp.status_code}") + try: + resp = requests.get(f'https://{site}', timeout=30) + if not resp.ok: + logger.info(f"Got bad status pinging app: {resp.status_code}") + except requests.exceptions.ReadTimeout: + logger.info("Timed out while pinging app external URL") else: logger.info("Could not fetch site external URL")