Skip to content

Commit 58c07dd

Browse files
committed
Allow head requests for the health endpoint
1 parent b81d913 commit 58c07dd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

binderhub/health.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ async def check_pod_quota(self):
151151
}
152152
return usage
153153

154-
async def get(self):
154+
async def check_all(self):
155+
"""Runs all health checks and returns a tuple (overall, checks).
156+
157+
`overall` is a bool representing the overall status of the service
158+
`checks` contains detailed information on each check's result
159+
"""
155160
checks = []
156161
check_futures = []
157162

@@ -176,7 +181,15 @@ async def get(self):
176181
overall = all(
177182
check["ok"] for check in checks if check["service"] != "Pod quota"
178183
)
184+
return overall, checks
185+
186+
async def get(self):
187+
overall, checks = await self.check_all()
179188
if not overall:
180189
self.set_status(503)
181-
182190
self.write({"ok": overall, "checks": checks})
191+
192+
async def head(self):
193+
overall, checks = await self.check_all()
194+
if not overall:
195+
self.set_status(503)

0 commit comments

Comments
 (0)