From 1f813b99fa99c4095152ac773608dff874b38255 Mon Sep 17 00:00:00 2001 From: Ankit Tripathi Date: Fri, 10 Jan 2025 03:12:01 -0800 Subject: [PATCH 1/4] Updated mode: http2 support --- paasta_tools/cli/cmds/info.py | 2 +- paasta_tools/cli/cmds/local_run.py | 2 +- paasta_tools/cli/schemas/smartstack_schema.json | 2 ++ paasta_tools/kubernetes_tools.py | 2 +- paasta_tools/long_running_service_tools.py | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/paasta_tools/cli/cmds/info.py b/paasta_tools/cli/cmds/info.py index 6904cd8182..6fb57e02db 100644 --- a/paasta_tools/cli/cmds/info.py +++ b/paasta_tools/cli/cmds/info.py @@ -37,7 +37,7 @@ ) # modes that depend on smartstack port cannot be tested via paasta proxies, so we exclude those -TESTABLE_SERVICE_MODES = {"http", "https"} +TESTABLE_SERVICE_MODES = {"http", "https", "http2"} def add_subparser(subparsers): diff --git a/paasta_tools/cli/cmds/local_run.py b/paasta_tools/cli/cmds/local_run.py index da3b88a0f3..fca0c93d20 100755 --- a/paasta_tools/cli/cmds/local_run.py +++ b/paasta_tools/cli/cmds/local_run.py @@ -168,7 +168,7 @@ def run_healthcheck_on_container( healthcheck_result = perform_cmd_healthcheck( docker_client, container_id, healthcheck_data, timeout ) - elif healthcheck_mode == "http" or healthcheck_mode == "https": + elif healthcheck_mode in ["http", "https", "http2"]: healthcheck_result = perform_http_healthcheck(healthcheck_data, timeout) elif healthcheck_mode == "tcp": healthcheck_result = perform_tcp_healthcheck(healthcheck_data, timeout) diff --git a/paasta_tools/cli/schemas/smartstack_schema.json b/paasta_tools/cli/schemas/smartstack_schema.json index 5314b0909f..cd07e335e3 100644 --- a/paasta_tools/cli/schemas/smartstack_schema.json +++ b/paasta_tools/cli/schemas/smartstack_schema.json @@ -37,6 +37,7 @@ "enum": [ "http", "https", + "http2", "tcp" ] }, @@ -117,6 +118,7 @@ "enum": [ "http", "https", + "http2", "tcp" ] }, diff --git a/paasta_tools/kubernetes_tools.py b/paasta_tools/kubernetes_tools.py index d5577f176d..159e8140ef 100644 --- a/paasta_tools/kubernetes_tools.py +++ b/paasta_tools/kubernetes_tools.py @@ -1371,7 +1371,7 @@ def get_liveness_probe( timeout_seconds=timeout_seconds, ) - if mode == "http" or mode == "https": + if mode in ["http", "https", "http2"]: path = self.get_healthcheck_uri(service_namespace_config) probe.http_get = V1HTTPGetAction( path=path, port=self.get_container_port(), scheme=mode.upper() diff --git a/paasta_tools/long_running_service_tools.py b/paasta_tools/long_running_service_tools.py index a4fcc0224e..99cd010a3e 100644 --- a/paasta_tools/long_running_service_tools.py +++ b/paasta_tools/long_running_service_tools.py @@ -110,7 +110,7 @@ def get_mode(self) -> str: return None else: return "http" - elif mode in ["http", "tcp", "https"]: + elif mode in ["http", "http2", "tcp", "https"]: return mode else: raise InvalidSmartstackMode("Unknown mode: %s" % mode) @@ -424,7 +424,7 @@ def get_healthcheck_for_instance( mode = service_manifest.get_healthcheck_mode(smartstack_config) hostname = socket.getfqdn() - if mode == "http" or mode == "https": + if mode in ["http", "https", "http2"]: path = service_manifest.get_healthcheck_uri(smartstack_config) healthcheck_command = "%s://%s:%d%s" % (mode, hostname, random_port, path) elif mode == "tcp": From f3605614bc42541f1557ef6e9cd69ef04fa5d175 Mon Sep 17 00:00:00 2001 From: Ankit Tripathi Date: Mon, 20 Jan 2025 07:38:00 -0800 Subject: [PATCH 2/4] update URL scheme handling in case of http2 mode. --- paasta_tools/cli/cmds/info.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/paasta_tools/cli/cmds/info.py b/paasta_tools/cli/cmds/info.py index 6fb57e02db..90da72b4b1 100644 --- a/paasta_tools/cli/cmds/info.py +++ b/paasta_tools/cli/cmds/info.py @@ -37,7 +37,7 @@ ) # modes that depend on smartstack port cannot be tested via paasta proxies, so we exclude those -TESTABLE_SERVICE_MODES = {"http", "https", "http2"} +TESTABLE_SERVICE_MODES = {"http", "https"} def add_subparser(subparsers): @@ -78,8 +78,9 @@ def get_smartstack_endpoints(service, soa_dir): service, full_name=False, soa_dir=soa_dir ): mode = config.get("mode", "http") + url_scheme = "http" if mode in ["http", "http2"] else mode port = config.get("proxy_port") - endpoints.append(f"{mode}://169.254.255.254:{port} ({name})") + endpoints.append(f"{url_scheme}://169.254.255.254:{port} ({name})") return endpoints @@ -96,10 +97,12 @@ def get_deployments_strings(service: str, soa_dir: str) -> List[str]: service=service, namespace="main", soa_dir=soa_dir ) service_mode = service_config.get_mode() + url_scheme = "http" if service_mode == "http2" else service_mode + for cluster in deployments_to_clusters(deployments): if service_mode in TESTABLE_SERVICE_MODES: link = PaastaColors.cyan( - f"{service_mode}://{service}.proxy.{cluster}.paasta/" + f"{url_scheme}://{service}.proxy.{cluster}.paasta/" ) else: link = "N/A" From 106753be90b2e91693865233964da1bccbe3af9e Mon Sep 17 00:00:00 2001 From: Ankit Tripathi Date: Mon, 20 Jan 2025 07:42:27 -0800 Subject: [PATCH 3/4] Add http2 handling for healthcheck mode --- paasta_tools/cli/cmds/local_run.py | 2 +- paasta_tools/kubernetes_tools.py | 2 +- paasta_tools/long_running_service_tools.py | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/paasta_tools/cli/cmds/local_run.py b/paasta_tools/cli/cmds/local_run.py index fca0c93d20..da3b88a0f3 100755 --- a/paasta_tools/cli/cmds/local_run.py +++ b/paasta_tools/cli/cmds/local_run.py @@ -168,7 +168,7 @@ def run_healthcheck_on_container( healthcheck_result = perform_cmd_healthcheck( docker_client, container_id, healthcheck_data, timeout ) - elif healthcheck_mode in ["http", "https", "http2"]: + elif healthcheck_mode == "http" or healthcheck_mode == "https": healthcheck_result = perform_http_healthcheck(healthcheck_data, timeout) elif healthcheck_mode == "tcp": healthcheck_result = perform_tcp_healthcheck(healthcheck_data, timeout) diff --git a/paasta_tools/kubernetes_tools.py b/paasta_tools/kubernetes_tools.py index 159e8140ef..d5577f176d 100644 --- a/paasta_tools/kubernetes_tools.py +++ b/paasta_tools/kubernetes_tools.py @@ -1371,7 +1371,7 @@ def get_liveness_probe( timeout_seconds=timeout_seconds, ) - if mode in ["http", "https", "http2"]: + if mode == "http" or mode == "https": path = self.get_healthcheck_uri(service_namespace_config) probe.http_get = V1HTTPGetAction( path=path, port=self.get_container_port(), scheme=mode.upper() diff --git a/paasta_tools/long_running_service_tools.py b/paasta_tools/long_running_service_tools.py index 99cd010a3e..251befe34c 100644 --- a/paasta_tools/long_running_service_tools.py +++ b/paasta_tools/long_running_service_tools.py @@ -93,9 +93,12 @@ def get_healthcheck_mode(self) -> str: """ healthcheck_mode = self.get("healthcheck_mode", None) if not healthcheck_mode: - return self.get_mode() - else: - return healthcheck_mode + mode = self.get_mode() + if mode == "http2": + healthcheck_mode = "http" + else: + healthcheck_mode = mode + return healthcheck_mode def get_mode(self) -> str: """Get the mode that the service runs in and check that we support it. @@ -424,7 +427,7 @@ def get_healthcheck_for_instance( mode = service_manifest.get_healthcheck_mode(smartstack_config) hostname = socket.getfqdn() - if mode in ["http", "https", "http2"]: + if mode == "http" or mode == "https": path = service_manifest.get_healthcheck_uri(smartstack_config) healthcheck_command = "%s://%s:%d%s" % (mode, hostname, random_port, path) elif mode == "tcp": From c06a2e9b70a2d82c7970617a79bf5337e7fa7913 Mon Sep 17 00:00:00 2001 From: Ankit Tripathi Date: Mon, 20 Jan 2025 08:03:10 -0800 Subject: [PATCH 4/4] condition for http is not required. --- paasta_tools/cli/cmds/info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paasta_tools/cli/cmds/info.py b/paasta_tools/cli/cmds/info.py index 90da72b4b1..952bad6158 100644 --- a/paasta_tools/cli/cmds/info.py +++ b/paasta_tools/cli/cmds/info.py @@ -78,7 +78,7 @@ def get_smartstack_endpoints(service, soa_dir): service, full_name=False, soa_dir=soa_dir ): mode = config.get("mode", "http") - url_scheme = "http" if mode in ["http", "http2"] else mode + url_scheme = "http" if mode == "http2" else mode port = config.get("proxy_port") endpoints.append(f"{url_scheme}://169.254.255.254:{port} ({name})") return endpoints