Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## master / unreleased

**This release removes support for chunks storage. See below for more.**
* [CHANGE] Remove support for chunks storage entirely. If you are using chunks storage on a previous version, you must [migrate your data](https://github.com/cortexproject/cortex/blob/v1.11.1/docs/blocks-storage/migrate-from-chunks-to-blocks.md) on version 1.12 or earlier. Before upgrading to this release, you should also remove any deprecated chunks-related configuration, as this release will no longer accept that. The following flags are gone:
- `-dynamodb.*`
Expand Down Expand Up @@ -45,6 +46,7 @@
* [FEATURE] Compactor: Added -compactor.blocks-fetch-concurrency` allowing to configure number of go routines for blocks during compaction. #4787
* [FEATURE] Compactor: Added configurations for Azure MSI in blocks-storage, ruler-storage and alertmanager-storage. #4818
* [BUGFIX] Memberlist: Add join with no retrying when starting service. #4804
* [BUGFIX] Ruler: Fix /ruler/rule_groups returns YAML with extra fields #4767

## 1.13.0 2022-07-14

Expand Down
2 changes: 1 addition & 1 deletion pkg/ruler/ruler.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ func (r *Ruler) ListAllRules(w http.ResponseWriter, req *http.Request) {
iter := make(chan interface{})

go func() {
util.StreamWriteYAMLResponse(w, iter, logger)
util.StreamWriteYAMLV3Response(w, iter, logger)
close(done)
}()

Expand Down
9 changes: 8 additions & 1 deletion pkg/ruler/ruler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/weaveworks/common/user"
"go.uber.org/atomic"
"google.golang.org/grpc"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"

"github.com/cortexproject/cortex/pkg/chunk/purger"
"github.com/cortexproject/cortex/pkg/cortexpb"
Expand Down Expand Up @@ -1123,6 +1123,13 @@ func TestRuler_ListAllRules(t *testing.T) {
for userID := range mockRules {
gs[userID] = mockRules[userID].Formatted()
}

// check for unnecessary fields
unnecessaryFields := []string{"kind", "style", "tag", "value", "anchor", "alias", "content", "headcomment", "linecomment", "footcomment", "line", "column"}
for _, word := range unnecessaryFields {
require.NotContains(t, string(body), word)
}

expectedResponse, err := yaml.Marshal(gs)
require.NoError(t, err)
require.YAMLEq(t, string(expectedResponse), string(body))
Expand Down
19 changes: 15 additions & 4 deletions pkg/util/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
"github.com/golang/snappy"
"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v2"
yamlv3 "gopkg.in/yaml.v3"
)

const messageSizeLargerErrFmt = "received message larger than max (%d vs %d)"
Expand Down Expand Up @@ -108,11 +109,11 @@ func RenderHTTPResponse(w http.ResponseWriter, v interface{}, t *template.Templa
}
}

// StreamWriteYAMLResponse stream writes data as http response
func StreamWriteYAMLResponse(w http.ResponseWriter, iter chan interface{}, logger log.Logger) {
// StreamWriteYAMLResponseCommon stream writes data as http response
func streamWriteYAMLResponseCommon(w http.ResponseWriter, iter chan interface{}, logger log.Logger, marshalFn func(in interface{}) (out []byte, err error)) {
w.Header().Set("Content-Type", "application/yaml")
for v := range iter {
data, err := yaml.Marshal(v)
data, err := marshalFn(v)
if err != nil {
level.Error(logger).Log("msg", "yaml marshal failed", "err", err)
continue
Expand All @@ -125,6 +126,16 @@ func StreamWriteYAMLResponse(w http.ResponseWriter, iter chan interface{}, logge
}
}

// StreamWriteYAMLResponse stream writes data as http response using yaml v2 library
func StreamWriteYAMLResponse(w http.ResponseWriter, iter chan interface{}, logger log.Logger) {
streamWriteYAMLResponseCommon(w, iter, logger, yaml.Marshal)
}

// StreamWriteYAMLV3Response stream writes data as http response using yaml v3 library
func StreamWriteYAMLV3Response(w http.ResponseWriter, iter chan interface{}, logger log.Logger) {
streamWriteYAMLResponseCommon(w, iter, logger, yamlv3.Marshal)
}

// CompressionType for encoding and decoding requests and responses.
type CompressionType int

Expand Down