diff --git a/cmd/thanos/receive.go b/cmd/thanos/receive.go index 42b5589b85b..ef37bf7d8ef 100644 --- a/cmd/thanos/receive.go +++ b/cmd/thanos/receive.go @@ -5,7 +5,6 @@ package main import ( "context" - "encoding/json" "net/http" "os" "path" @@ -314,25 +313,13 @@ func runReceive( httpserver.WithGracePeriod(time.Duration(*conf.httpGracePeriod)), httpserver.WithTLSConfig(*conf.httpTLSConfig), ) - var lastDownscalePrepareTimestamp int64 = 0 srv.Handle("/-/downscale", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { n := dbs.GetTenantsLen() w.Header().Set("Tenant-Count", strconv.Itoa(n)) - w.WriteHeader(http.StatusOK) - if r.Method == http.MethodDelete { - return - } - w.Header().Set("Content-Type", "application/json") - if lastDownscalePrepareTimestamp == 0 || n > 0 { - lastDownscalePrepareTimestamp = time.Now().Unix() - } - err := json.NewEncoder(w).Encode(struct { - Timestamp int64 `json:"timestamp"` - }{ - Timestamp: lastDownscalePrepareTimestamp, - }) - if err != nil { - level.Error(logger).Log("msg", "error writing downscale response", "err", err) + if n > 0 { + w.WriteHeader(http.StatusTooEarly) + } else { + w.WriteHeader(http.StatusOK) } })) g.Add(func() error {