|
18 | 18 | from aleph_message.models import InstanceContent, ItemHash, MessageType, PaymentType
|
19 | 19 | from pydantic import ValidationError
|
20 | 20 |
|
| 21 | +from aleph.vm import haproxy |
21 | 22 | from aleph.vm.conf import settings
|
22 | 23 | from aleph.vm.controllers.firecracker.executable import (
|
23 | 24 | ResourceDownloadError,
|
@@ -148,6 +149,26 @@ async def about_login(request: web.Request) -> web.Response:
|
148 | 149 | return web.json_response({"success": False}, status=401)
|
149 | 150 |
|
150 | 151 |
|
| 152 | +async def debug_haproxy(request: web.Request) -> web.Response: |
| 153 | + """ "Debug endpoint to check the status of HAProxy and the domains mapped to it. |
| 154 | +
|
| 155 | + This is a debug endpoint and should not be used in production. The interface is subject to change. |
| 156 | + """ |
| 157 | + socket = settings.HAPROXY_SOCKET |
| 158 | + import pathlib |
| 159 | + |
| 160 | + if not pathlib.Path(socket).exists(): |
| 161 | + logger.info("HAProxy not running? socket not found, skip domain mapping update") |
| 162 | + return web.json_response({"status": "no socket"}, status=http.HTTPStatus) |
| 163 | + r: dict = {"status": "ok", "backends": {}} |
| 164 | + for backend in haproxy.HAPROXY_BACKENDS: |
| 165 | + r["backends"][str(backend["name"])] = haproxy.get_current_backends(socket, backend["name"]) |
| 166 | + return web.json_response( |
| 167 | + r, |
| 168 | + dumps=dumps_for_json, |
| 169 | + ) |
| 170 | + |
| 171 | + |
151 | 172 | @cors_allow_all
|
152 | 173 | async def about_executions(request: web.Request) -> web.Response:
|
153 | 174 | "/about/executions/details Debugging endpoint with full execution details."
|
|
0 commit comments