mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Forgot api files for removing HEAD
Signed-off-by: Alex Greenbank <alex.greenbank@grafana.com>
This commit is contained in:
parent
1651f8fab2
commit
3ff2f4ecab
|
@ -210,10 +210,9 @@ type API struct {
|
||||||
isAgent bool
|
isAgent bool
|
||||||
statsRenderer StatsRenderer
|
statsRenderer StatsRenderer
|
||||||
|
|
||||||
remoteWriteHeadHandler http.Handler
|
remoteWriteHandler http.Handler
|
||||||
remoteWriteHandler http.Handler
|
remoteReadHandler http.Handler
|
||||||
remoteReadHandler http.Handler
|
otlpWriteHandler http.Handler
|
||||||
otlpWriteHandler http.Handler
|
|
||||||
|
|
||||||
codecs []Codec
|
codecs []Codec
|
||||||
}
|
}
|
||||||
|
@ -290,20 +289,7 @@ func NewAPI(
|
||||||
}
|
}
|
||||||
|
|
||||||
if rwEnabled {
|
if rwEnabled {
|
||||||
// TODO(alexg) - Two phase rwFormat rollout needs to create handlers with flag for advertising.
|
|
||||||
// For rollout we do two phases:
|
|
||||||
// 0. (Before) no flags set
|
|
||||||
// 1. (During) support new protocols but don't advertise
|
|
||||||
// <wait until all servers have rolled out and now support RW2.0>
|
|
||||||
// 2. (After) support new protocols and advertise
|
|
||||||
//
|
|
||||||
// For rollback the two phases are:
|
|
||||||
// 0. (Before) support new protocols and advertise
|
|
||||||
// 1. (During) support new protocols but don't advertise
|
|
||||||
// <wait a suitable period for all sending clients to be aware that receiving servers no longer support 2.0>
|
|
||||||
// 2. (After) no flags set
|
|
||||||
a.remoteWriteHandler = remote.NewWriteHandler(logger, registerer, ap, rwFormat)
|
a.remoteWriteHandler = remote.NewWriteHandler(logger, registerer, ap, rwFormat)
|
||||||
a.remoteWriteHeadHandler = remote.NewWriteHeadHandler(logger, registerer, rwFormat)
|
|
||||||
}
|
}
|
||||||
if otlpEnabled {
|
if otlpEnabled {
|
||||||
a.otlpWriteHandler = remote.NewOTLPWriteHandler(logger, ap)
|
a.otlpWriteHandler = remote.NewOTLPWriteHandler(logger, ap)
|
||||||
|
@ -400,7 +386,6 @@ func (api *API) Register(r *route.Router) {
|
||||||
r.Get("/status/walreplay", api.serveWALReplayStatus)
|
r.Get("/status/walreplay", api.serveWALReplayStatus)
|
||||||
r.Post("/read", api.ready(api.remoteRead))
|
r.Post("/read", api.ready(api.remoteRead))
|
||||||
r.Post("/write", api.ready(api.remoteWrite))
|
r.Post("/write", api.ready(api.remoteWrite))
|
||||||
r.Head("/write", api.remoteWriteHead)
|
|
||||||
r.Post("/otlp/v1/metrics", api.ready(api.otlpWrite))
|
r.Post("/otlp/v1/metrics", api.ready(api.otlpWrite))
|
||||||
|
|
||||||
r.Get("/alerts", wrapAgent(api.alerts))
|
r.Get("/alerts", wrapAgent(api.alerts))
|
||||||
|
@ -1661,14 +1646,6 @@ func (api *API) remoteRead(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) remoteWriteHead(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if api.remoteWriteHeadHandler != nil {
|
|
||||||
api.remoteWriteHeadHandler.ServeHTTP(w, r)
|
|
||||||
} else {
|
|
||||||
http.Error(w, "remote write receiver needs to be enabled with --web.enable-remote-write-receiver", http.StatusNotFound)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (api *API) remoteWrite(w http.ResponseWriter, r *http.Request) {
|
func (api *API) remoteWrite(w http.ResponseWriter, r *http.Request) {
|
||||||
if api.remoteWriteHandler != nil {
|
if api.remoteWriteHandler != nil {
|
||||||
api.remoteWriteHandler.ServeHTTP(w, r)
|
api.remoteWriteHandler.ServeHTTP(w, r)
|
||||||
|
|
|
@ -337,48 +337,6 @@ var sampleFlagMap = map[string]string{
|
||||||
"flag2": "value2",
|
"flag2": "value2",
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHeadEndpoint(t *testing.T) {
|
|
||||||
for _, tc := range []struct {
|
|
||||||
name string
|
|
||||||
rwFormat config.RemoteWriteFormat
|
|
||||||
expectedStatusCode int
|
|
||||||
expectedHeaderValue string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "HEAD Version 1",
|
|
||||||
rwFormat: remote.Version1,
|
|
||||||
expectedStatusCode: http.StatusOK,
|
|
||||||
expectedHeaderValue: "0.1.0",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "HEAD Version 2",
|
|
||||||
rwFormat: remote.Version2,
|
|
||||||
expectedStatusCode: http.StatusOK,
|
|
||||||
expectedHeaderValue: "2.0;snappy,0.1.0",
|
|
||||||
},
|
|
||||||
} {
|
|
||||||
r := route.New()
|
|
||||||
api := &API{
|
|
||||||
remoteWriteHeadHandler: remote.NewWriteHeadHandler(log.NewNopLogger(), nil, tc.rwFormat),
|
|
||||||
ready: func(f http.HandlerFunc) http.HandlerFunc { return f },
|
|
||||||
}
|
|
||||||
api.Register(r)
|
|
||||||
|
|
||||||
s := httptest.NewServer(r)
|
|
||||||
defer s.Close()
|
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodHead, s.URL+"/write", nil)
|
|
||||||
require.NoError(t, err, "Error creating HEAD request")
|
|
||||||
client := &http.Client{}
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
require.NoError(t, err, "Error executing HEAD request")
|
|
||||||
require.Equal(t, tc.expectedStatusCode, resp.StatusCode)
|
|
||||||
|
|
||||||
promHeader := resp.Header.Get(remote.RemoteWriteVersionHeader)
|
|
||||||
require.Equal(t, tc.expectedHeaderValue, promHeader)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEndpoints(t *testing.T) {
|
func TestEndpoints(t *testing.T) {
|
||||||
storage := promql.LoadedStorage(t, `
|
storage := promql.LoadedStorage(t, `
|
||||||
load 1m
|
load 1m
|
||||||
|
|
Loading…
Reference in a new issue