Skip to content

Commit f7ef57f

Browse files
authored
PRW2: Change prw2 push success response code (#7050)
1 parent 3128901 commit f7ef57f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pkg/util/push/push.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func Handler(remoteWrite2Enabled bool, maxRecvMsgSize int, sourceIPs *middleware
114114
http.Error(w, string(resp.Body), int(resp.Code))
115115
} else {
116116
setPRW2RespHeader(w, resp.Samples, resp.Histograms, resp.Exemplars)
117+
w.WriteHeader(http.StatusNoContent)
117118
}
118119
}
119120

pkg/util/push/push_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func TestHandler_remoteWrite(t *testing.T) {
231231
req := createRequest(t, createPrometheusRemoteWriteV2Protobuf(t), true)
232232
resp := httptest.NewRecorder()
233233
handler.ServeHTTP(resp, req)
234-
assert.Equal(t, http.StatusOK, resp.Code)
234+
assert.Equal(t, http.StatusNoContent, resp.Code)
235235

236236
// test header value
237237
respHeader := resp.Header()
@@ -258,7 +258,7 @@ func TestHandler_ContentTypeAndEncoding(t *testing.T) {
258258
"Content-Encoding": "snappy",
259259
remoteWriteVersionHeader: "2.0.0",
260260
},
261-
expectedCode: http.StatusOK,
261+
expectedCode: http.StatusNoContent,
262262
isV2: true,
263263
},
264264
{
@@ -321,7 +321,7 @@ func TestHandler_ContentTypeAndEncoding(t *testing.T) {
321321
"Content-Type": appProtoV2ContentType,
322322
remoteWriteVersionHeader: "2.0.0",
323323
},
324-
expectedCode: http.StatusOK,
324+
expectedCode: http.StatusNoContent,
325325
isV2: true,
326326
},
327327
{
@@ -330,7 +330,7 @@ func TestHandler_ContentTypeAndEncoding(t *testing.T) {
330330
"Content-Type": appProtoV2ContentType,
331331
"Content-Encoding": "snappy",
332332
},
333-
expectedCode: http.StatusOK,
333+
expectedCode: http.StatusNoContent,
334334
isV2: true,
335335
},
336336
{
@@ -375,7 +375,7 @@ func TestHandler_cortexWriteRequest(t *testing.T) {
375375
req := createRequest(t, createCortexRemoteWriteV2Protobuf(t, false, cortexpb.API), true)
376376
resp := httptest.NewRecorder()
377377
handler.ServeHTTP(resp, req)
378-
assert.Equal(t, 200, resp.Code)
378+
assert.Equal(t, http.StatusNoContent, resp.Code)
379379
})
380380
}
381381

0 commit comments

Comments
 (0)