Skip to content

Commit 308e038

Browse files
Allenzhliallenzhli
authored andcommitted
Update CHANGELOG.md
Co-authored-by: Marco Pracucci <[email protected]> Update CHANGELOG.md Co-authored-by: Marco Pracucci <[email protected]> Update pkg/ruler/ruler_test.go Co-authored-by: Marco Pracucci <[email protected]> Update pkg/util/http_test.go Co-authored-by: Marco Pracucci <[email protected]> Update pkg/alertmanager/api_test.go Co-authored-by: Marco Pracucci <[email protected]> Update pkg/alertmanager/api_test.go Co-authored-by: Marco Pracucci <[email protected]> Update pkg/alertmanager/api.go Co-authored-by: Marco Pracucci <[email protected]> fix review comments Signed-off-by: allenzhli <[email protected]>
1 parent cf87955 commit 308e038

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
* [ENHANCEMENT] Ruler: added the following metrics when ruler sharding is enabled: #3916
2828
* `cortex_ruler_clients`
2929
* `cortex_ruler_client_request_duration_seconds`
30-
* [ENHANCEMENT] Alertmanager: Add API endpoint to list all tenant alertmanager configs: `GET /multitenant_alertmanager/configs`. #3259
31-
* [ENHANCEMENT] Ruler: Add API endpoint to list all tenant ruler rule groups: `GET /ruler/rule_groups`. #3259
30+
* [ENHANCEMENT] Alertmanager: Add API endpoint to list all tenant alertmanager configs: `GET /multitenant_alertmanager/configs`. #3529
31+
* [ENHANCEMENT] Ruler: Add API endpoint to list all tenant ruler rule groups: `GET /ruler/rule_groups`. #3529
3232
* [ENHANCEMENT] Query-frontend/scheduler: added querier forget delay (`-query-frontend.querier-forget-delay` and `-query-scheduler.querier-forget-delay`) to mitigate the blast radius in the event queriers crash because of a repeatedly sent "query of death" when shuffle-sharding is enabled. #3901
3333
* [ENHANCEMENT] Query-frontend: reduced memory allocations when serializing query response. #3964
3434
* [ENHANCEMENT] Querier / ruler: some optimizations to PromQL query engine. #3934 #3989

pkg/alertmanager/api.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/pkg/errors"
1212

1313
"github.com/cortexproject/cortex/pkg/alertmanager/alertspb"
14-
"github.com/cortexproject/cortex/pkg/chunk"
1514
"github.com/cortexproject/cortex/pkg/tenant"
1615
"github.com/cortexproject/cortex/pkg/util"
1716
"github.com/cortexproject/cortex/pkg/util/concurrency"
@@ -213,7 +212,7 @@ func (am *MultitenantAlertmanager) ListAllConfigs(w http.ResponseWriter, r *http
213212

214213
err = concurrency.ForEachUser(r.Context(), userIDs, fetchConcurrency, func(ctx context.Context, userID string) error {
215214
cfg, err := am.store.GetAlertConfig(ctx, userID)
216-
if errors.Is(err, chunk.ErrStorageObjectNotFound) {
215+
if errors.Is(err, alertspb.ErrNotFound) {
217216
return nil
218217
} else if err != nil {
219218
return errors.Wrapf(err, "failed to fetch alertmanager config for user %s", userID)

pkg/alertmanager/api_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ receivers:
283283
resp := w.Result()
284284
require.Equal(t, http.StatusOK, resp.StatusCode)
285285
require.Equal(t, "application/yaml", resp.Header.Get("Content-Type"))
286-
body, _ := ioutil.ReadAll(resp.Body)
287-
old, _ := yaml.Marshal(testCases)
286+
body, err := ioutil.ReadAll(resp.Body)
287+
require.NoError(t, err)
288+
old, err := yaml.Marshal(testCases)
289+
require.NoError(t, err)
288290
require.YAMLEq(t, string(old), string(body))
289291
}

pkg/ruler/ruler.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/weaveworks/common/user"
2525
"golang.org/x/sync/errgroup"
2626

27-
"github.com/cortexproject/cortex/pkg/chunk"
2827
"github.com/cortexproject/cortex/pkg/cortexpb"
2928
"github.com/cortexproject/cortex/pkg/ring"
3029
ring_client "github.com/cortexproject/cortex/pkg/ring/client"
@@ -866,9 +865,7 @@ func (r *Ruler) ListAllRules(w http.ResponseWriter, req *http.Request) {
866865

867866
err = concurrency.ForEachUser(req.Context(), userIDs, fetchRulesConcurrency, func(ctx context.Context, userID string) error {
868867
rg, err := r.store.ListRuleGroupsForUserAndNamespace(ctx, userID, "")
869-
if errors.Is(err, chunk.ErrStorageObjectNotFound) {
870-
return nil
871-
} else if err != nil {
868+
if err != nil {
872869
return errors.Wrapf(err, "failed to fetch ruler config for user %s", userID)
873870
}
874871
data := map[string]map[string][]rulefmt.RuleGroup{userID: rg.Formatted()}

pkg/ruler/ruler_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ func TestRuler_ListAllRules(t *testing.T) {
856856
router := mux.NewRouter()
857857
router.Path("/ruler/rule_groups").Methods(http.MethodGet).HandlerFunc(r.ListAllRules)
858858

859-
// Verify namespace1 rules are there.
860859
req := requestFor(t, http.MethodGet, "https://localhost:8080/ruler/rule_groups", nil, "")
861860
w := httptest.NewRecorder()
862861
router.ServeHTTP(w, req)
@@ -868,12 +867,12 @@ func TestRuler_ListAllRules(t *testing.T) {
868867
require.Equal(t, http.StatusOK, resp.StatusCode)
869868
require.Equal(t, "application/yaml", resp.Header.Get("Content-Type"))
870869

871-
// Testing the running rules for user1 in the mock store
872870
gs := make(map[string]map[string][]rulefmt.RuleGroup) // user:namespace:[]rulefmt.RuleGroup
873871
for userID := range mockRules {
874872
gs[userID] = mockRules[userID].Formatted()
875873
}
876-
expectedResponse, _ := yaml.Marshal(gs)
874+
expectedResponse, err := yaml.Marshal(gs)
875+
require.NoError(t, err)
877876
require.YAMLEq(t, string(expectedResponse), string(body))
878877
}
879878

pkg/util/http_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"testing"
1313

1414
"github.com/stretchr/testify/assert"
15+
"github.com/stretchr/testify/require"
1516
"gopkg.in/yaml.v2"
1617

1718
"github.com/cortexproject/cortex/pkg/cortexpb"
@@ -114,7 +115,8 @@ func TestStreamWriteYAMLResponse(t *testing.T) {
114115
}
115116
tt.value[ts.Name] = &ts
116117
}
117-
d, _ := yaml.Marshal(tt.value)
118+
d, err := yaml.Marshal(tt.value)
119+
require.NoError(t, err)
118120
tt.expectedOutput = string(d)
119121
w := httptest.NewRecorder()
120122

0 commit comments

Comments
 (0)