1
0
mirror of https://github.com/prometheus/alertmanager.git synced 2026-10-24 20:39:28 +03:00

4 Commits

Author SHA1 Message Date
Solomon Jacobs
9a94fb2280 httpserver: return 503 on cancelled reload requests
422 Unprocessable Entity means a well-formed request with invalid
semantics, which does not fit a cancelled request. The request
context is also cancelled on server shutdown, where 503 Service
Unavailable is the conventional response.

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
2026-08-19 11:59:49 +02:00
Solomon Jacobs
c21959fe30 httpserver: improve reload handler tests
Use testing/synctest for deterministic scheduling.

Move all require.* assertions into the test goroutine, since
require.FailNow must not be called from other goroutines.

Use t.Context() and http.MethodPost, and deduplicate the handler
goroutine into a serveReload helper.

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
2026-08-19 11:59:49 +02:00
June Kim
1193873419 httpserver: make /-/reload handler cancellation-safe
Fix three bugs in the reload handler identified in #5103:

1. Use a buffered error channel (size 1) so the reloader goroutine
   never blocks if the HTTP client disconnects before reading the
   result.

2. Remove the incorrect `defer close(errc)` — the handler is the
   receiver, not the sender; closing from the receiver side could
   panic the sender.

3. Wrap both the enqueue (send to reloadCh) and the reply (receive
   from errc) in select statements that also listen on
   req.Context().Done(), so a client disconnect unblocks the handler
   at either stage.

Fixes #5103

Signed-off-by: June Kim <kimjune01@gmail.com>
Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
2026-08-19 11:59:49 +02:00
Solomon Jacobs
b6490116c7 ui: Move useful parts to httpserver (#5097)
In the future, we want to remove the ui build artifacts from the
repository. This will break the usages of

```sh
go get github.com/prometheus/alertmanager/ui
```

That is exactly as expected, since the ui can't function correctly
without the ui artefacts.

This change attempts to make the transition a bit less painful.

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
2026-03-26 20:24:39 +01:00