Skip to content

Commit d72a357

Browse files
committed
Review comments.
Signed-off-by: Steve Simpson <[email protected]>
1 parent 3a9f166 commit d72a357

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

integration/alertmanager_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func TestAlertmanagerSharding(t *testing.T) {
499499
require.NoError(t, err)
500500
}
501501

502-
// Endpoint: GET /alerts
502+
// Endpoint: GET /v1/alerts
503503
{
504504
// Reads will query at least two replicas and merge the results.
505505
// Therefore, the alerts we posted should always be visible.

pkg/alertmanager/distributor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func respondFromMultipleHTTPGRPCResponses(w http.ResponseWriter, logger log.Logg
313313
}
314314

315315
// It is assumed by using this function, the caller knows that the responses it receives
316-
// have already need checked for success or failure, and that the headers will always
316+
// have already been checked for success or failure, and that the headers will always
317317
// match due to the nature of the request. If this is not the case, a different merge
318318
// function should be implemented to cope with the differing responses.
319319
response := &httpgrpc.HTTPResponse{

pkg/alertmanager/merger/merger.go

+3
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ type Merger interface {
1111
type Noop struct{}
1212

1313
func (Noop) MergeResponses(in [][]byte) ([]byte, error) {
14+
if len(in) == 0 {
15+
return nil, nil
16+
}
1417
return in[0], nil
1518
}

pkg/alertmanager/merger/v1_alerts.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ func (V1Alerts) MergeResponses(in [][]byte) ([]byte, error) {
4545
Data: merged,
4646
}
4747

48-
result, err := json.Marshal(body)
49-
if err != nil {
50-
return nil, err
51-
}
52-
53-
return result, nil
48+
return json.Marshal(body)
5449
}
5550

5651
func mergeV1Alerts(in []*v1.Alert) ([]*v1.Alert, error) {

0 commit comments

Comments
 (0)