Skip to content

Commit

Permalink
Add http2 handling for healthcheck mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit864 committed Jan 20, 2025
1 parent f360561 commit 106753b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion paasta_tools/cli/cmds/local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion paasta_tools/kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 7 additions & 4 deletions paasta_tools/long_running_service_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 106753b

Please sign in to comment.