-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Relevant code part:
https://github.com/thanos-io/thanos/blob/master/cmd/thanos/rule.go#L553-L564
I wrote this in kind of pseudo-code, I hope that's understandable.
The prefix after all of the wrapping that we use for API end-points is /{USER_STRING}api/v1. In the /-/reload case after all of the wrapping there, the prefix that we use when registering a route is /{USER_STRING}. Then, the /-/reload is registered on top of that prefix. The crux of the issue is that the prefix, in this case, ends with a / when no USER_STRING has been specified leading to a 404 when /-/reload is accessed.
Testing on v0.12.1:
$ curl --fail -X POST http://localhost:${HTTP_PORT}/-/reload
curl: (22) The requested URL returned error: 404 Not Found
With a simple change to:
router.WithPrefix(webRoutePrefix).Post("-/reload", func(w http.ResponseWriter, r *http.Request) {
It works again:
{"caller":"rule.go:783","level":"info","msg":"reload rule files","numFiles":1,"ts":"2020-04-23T15:09:45.569659899Z"}
But this "fix" doesn't handle the case when the user passes us some string. If some string has been passed then the route needs to be with the prefix /. If no string has been passed then it needs to be without the prefix /.
Or just remove this router.WithPrefix(webRoutePrefix) part on that line because it is already handled by us previously.