From c229cb858f52ea57244ba2c41fdf83390ce1b184 Mon Sep 17 00:00:00 2001 From: Zhivko Draganov Date: Tue, 1 Oct 2024 15:34:06 +0300 Subject: [PATCH 1/8] fix: reenable healthz endpoint for Ben --- src/starlette_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/starlette_api.py b/src/starlette_api.py index a23ee22e..bb6fb9d5 100644 --- a/src/starlette_api.py +++ b/src/starlette_api.py @@ -314,7 +314,7 @@ async def dispatch(self, request, call_next): Route('/check_claim', check_claim, methods=['POST']), Route('/play_full_board', play_full_board, methods=['POST']), Route('/alert_bid', alert_bid, methods=['POST']), - # Route('/healthz', healthz, methods=['GET']) + Route('/healthz', healthz, methods=['GET']) ], middleware=[ Middleware(OpenTelemetryMiddleware), From beb7cf4124dbd691e03ebd5e6638b78a145cede3 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Tue, 1 Oct 2024 12:35:23 +0000 Subject: [PATCH 2/8] chore(release): 0.9.1 --- CHANGELOG.md | 4 ++-- VERSION | 2 +- version.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba15f863..e3b34a90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## [0.9.0](https://github.com/Seven-of-Di/ben/compare/v0.8.0...v0.9.0) (2024-06-26) +### [0.9.1](https://github.com/Seven-of-Di/ben/compare/v0.9.0...v0.9.1) (2024-10-01) ### Bug Fixes -* Parenthesis fix, Lia was accepting the claim too agressively ([e4a5ba2](https://github.com/Seven-of-Di/ben/commit/e4a5ba2b2c7b894270f3f7141094cc887fc63aa2)) +* reenable healthz endpoint for Ben ([c229cb8](https://github.com/Seven-of-Di/ben/commit/c229cb858f52ea57244ba2c41fdf83390ce1b184)) diff --git a/VERSION b/VERSION index 899f24fc..f514a2f0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.0 \ No newline at end of file +0.9.1 \ No newline at end of file diff --git a/version.json b/version.json index 2069fe23..3b76ad74 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "0.9.0" + "version": "0.9.1" } From 52087a1b1664198dea09d3e1f6847d4846fcd2b9 Mon Sep 17 00:00:00 2001 From: Zhivko Draganov Date: Tue, 1 Oct 2024 15:59:08 +0300 Subject: [PATCH 3/8] fix: switch to simple HTTP API access healthcheck --- src/starlette_api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/starlette_api.py b/src/starlette_api.py index bb6fb9d5..2ae6e206 100644 --- a/src/starlette_api.py +++ b/src/starlette_api.py @@ -264,11 +264,12 @@ async def alert_bid(request: Request): health_checker = HealthChecker() async def healthz(): - healthy = health_checker.healthy() - if healthy: - return 'ok', 200 + return 'ok', 200 + # healthy = health_checker.healthy() + # if healthy: + # return 'ok', 200 - return 'unhealthy', 500 + # return 'unhealthy', 500 class TracingHeaderMiddleware(BaseHTTPMiddleware): async def dispatch(self, request, call_next): From f5d6229419e3e12fb2142aaef8a2750cf36fca0c Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Tue, 1 Oct 2024 13:00:45 +0000 Subject: [PATCH 4/8] chore(release): 0.9.2 --- CHANGELOG.md | 4 ++-- VERSION | 2 +- version.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3b34a90..331df32a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -### [0.9.1](https://github.com/Seven-of-Di/ben/compare/v0.9.0...v0.9.1) (2024-10-01) +### [0.9.2](https://github.com/Seven-of-Di/ben/compare/v0.9.1...v0.9.2) (2024-10-01) ### Bug Fixes -* reenable healthz endpoint for Ben ([c229cb8](https://github.com/Seven-of-Di/ben/commit/c229cb858f52ea57244ba2c41fdf83390ce1b184)) +* switch to simple HTTP API access healthcheck ([52087a1](https://github.com/Seven-of-Di/ben/commit/52087a1b1664198dea09d3e1f6847d4846fcd2b9)) diff --git a/VERSION b/VERSION index f514a2f0..f76f9131 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.1 \ No newline at end of file +0.9.2 \ No newline at end of file diff --git a/version.json b/version.json index 3b76ad74..5eba2ab3 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "0.9.1" + "version": "0.9.2" } From b90471ef2d6674c7a0fa99ed9e1fa65e6020fe59 Mon Sep 17 00:00:00 2001 From: Zhivko Draganov Date: Tue, 1 Oct 2024 16:34:17 +0300 Subject: [PATCH 5/8] fix: properly start the healthchecker and use starlette Response object --- src/health_checker.py | 2 -- src/starlette_api.py | 15 ++++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/health_checker.py b/src/health_checker.py index 86f448bc..1f024b9f 100644 --- a/src/health_checker.py +++ b/src/health_checker.py @@ -1,7 +1,6 @@ import psutil import threading from typing import List -import logging class HealthChecker: cpu_usage: List[float] @@ -12,7 +11,6 @@ def __init__(self) -> None: def healthy(self) -> bool: for cpu_per_core in self.cpu_usage: if cpu_per_core > 95: - logging.warning(self.cpu_usage) return False return True diff --git a/src/starlette_api.py b/src/starlette_api.py index 2ae6e206..169cc6a2 100644 --- a/src/starlette_api.py +++ b/src/starlette_api.py @@ -7,6 +7,7 @@ from starlette.responses import JSONResponse from starlette.routing import Route from starlette.requests import Request +from starlette.responses import Response from starlette.middleware.base import BaseHTTPMiddleware from opentelemetry import trace from starlette_exporter import PrometheusMiddleware, handle_metrics, CollectorRegistry, multiprocess # type: ignore @@ -75,7 +76,6 @@ def __init__(self, play_card_request): self.playing_mode = PlayingMode.from_str(play_card_request[ "playing_mode"]) if "playing_mode" in play_card_request else PlayingMode.MATCHPOINTS - class MakeLead: def __init__(self, make_lead_request): self.hand = make_lead_request['hand'] @@ -262,14 +262,15 @@ async def alert_bid(request: Request): return {'error': str(e)},500 health_checker = HealthChecker() +health_checker.start() -async def healthz(): - return 'ok', 200 - # healthy = health_checker.healthy() - # if healthy: - # return 'ok', 200 +async def healthz(_: Request): + # return Response("OK", status_code=200) + healthy = health_checker.healthy() + if healthy: + return Response("OK", status_code=200) - # return 'unhealthy', 500 + return Response("FAILURE", status_code=500) class TracingHeaderMiddleware(BaseHTTPMiddleware): async def dispatch(self, request, call_next): From 4d0fa3aa73c334576482da8c7bb379087d4435e5 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Tue, 1 Oct 2024 13:36:19 +0000 Subject: [PATCH 6/8] chore(release): 0.9.3 --- CHANGELOG.md | 4 ++-- VERSION | 2 +- version.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 331df32a..d26aa006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -### [0.9.2](https://github.com/Seven-of-Di/ben/compare/v0.9.1...v0.9.2) (2024-10-01) +### [0.9.3](https://github.com/Seven-of-Di/ben/compare/v0.9.2...v0.9.3) (2024-10-01) ### Bug Fixes -* switch to simple HTTP API access healthcheck ([52087a1](https://github.com/Seven-of-Di/ben/commit/52087a1b1664198dea09d3e1f6847d4846fcd2b9)) +* properly start the healthchecker and use starlette Response object ([b90471e](https://github.com/Seven-of-Di/ben/commit/b90471ef2d6674c7a0fa99ed9e1fa65e6020fe59)) diff --git a/VERSION b/VERSION index f76f9131..b3ec1638 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.2 \ No newline at end of file +0.9.3 \ No newline at end of file diff --git a/version.json b/version.json index 5eba2ab3..364e73ec 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "0.9.2" + "version": "0.9.3" } From b7e747b885379862229c58bc280e3cd523b1be56 Mon Sep 17 00:00:00 2001 From: Zhivko Draganov Date: Tue, 1 Oct 2024 17:33:06 +0300 Subject: [PATCH 7/8] fix: revert to simple http healthcheck --- src/starlette_api.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/starlette_api.py b/src/starlette_api.py index 169cc6a2..77c66bc7 100644 --- a/src/starlette_api.py +++ b/src/starlette_api.py @@ -261,16 +261,16 @@ async def alert_bid(request: Request): logging.exception(e) return {'error': str(e)},500 -health_checker = HealthChecker() -health_checker.start() +# health_checker = HealthChecker() +# health_checker.start() async def healthz(_: Request): - # return Response("OK", status_code=200) - healthy = health_checker.healthy() - if healthy: - return Response("OK", status_code=200) + return Response("OK", status_code=200) + # healthy = health_checker.healthy() + # if healthy: + # return Response("OK", status_code=200) - return Response("FAILURE", status_code=500) + # return Response("FAILURE", status_code=500) class TracingHeaderMiddleware(BaseHTTPMiddleware): async def dispatch(self, request, call_next): From 8c37be4b962b6d063e351df0ef430160e7a7d51b Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Tue, 1 Oct 2024 14:39:41 +0000 Subject: [PATCH 8/8] chore(release): 0.9.4 --- CHANGELOG.md | 4 ++-- VERSION | 2 +- version.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d26aa006..dd4c468c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -### [0.9.3](https://github.com/Seven-of-Di/ben/compare/v0.9.2...v0.9.3) (2024-10-01) +### [0.9.4](https://github.com/Seven-of-Di/ben/compare/v0.9.3...v0.9.4) (2024-10-01) ### Bug Fixes -* properly start the healthchecker and use starlette Response object ([b90471e](https://github.com/Seven-of-Di/ben/commit/b90471ef2d6674c7a0fa99ed9e1fa65e6020fe59)) +* revert to simple http healthcheck ([b7e747b](https://github.com/Seven-of-Di/ben/commit/b7e747b885379862229c58bc280e3cd523b1be56)) diff --git a/VERSION b/VERSION index b3ec1638..2bd77c74 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.3 \ No newline at end of file +0.9.4 \ No newline at end of file diff --git a/version.json b/version.json index 364e73ec..676f2c1b 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "0.9.3" + "version": "0.9.4" }