Skip to content

Commit

Permalink
Update to latest dskit for cache changes (#7155)
Browse files Browse the repository at this point in the history
Specifically pulls in grafana/dskit#466 which changes the `RemoteCacheClient`
interface and Memcached/Redis implementations of it, removing an impossible
error return.

Signed-off-by: Nick Pillitteri <[email protected]>
  • Loading branch information
56quarters authored Jan 17, 2024
1 parent 52c39fb commit a56442d
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 1,324 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/golang/snappy v0.0.4
github.com/google/gopacket v1.1.19
github.com/gorilla/mux v1.8.1
github.com/grafana/dskit v0.0.0-20240112005349-f30e65d9dee2
github.com/grafana/dskit v0.0.0-20240117144322-b9a439dedeb8
github.com/grafana/e2e v0.1.1
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/json-iterator/go v1.1.12
Expand Down Expand Up @@ -226,7 +226,6 @@ require (
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
Expand Down
7 changes: 2 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ github.com/gosimple/slug v1.1.1 h1:fRu/digW+NMwBIP+RmviTK97Ho/bEj/C9swrCspN3D4=
github.com/gosimple/slug v1.1.1/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0=
github.com/grafana-tools/sdk v0.0.0-20220919052116-6562121319fc h1:PXZQA2WCxe85Tnn+WEvr8fDpfwibmEPgfgFEaC87G24=
github.com/grafana-tools/sdk v0.0.0-20220919052116-6562121319fc/go.mod h1:AHHlOEv1+GGQ3ktHMlhuTUwo3zljV3QJbC0+8o2kn+4=
github.com/grafana/dskit v0.0.0-20240112005349-f30e65d9dee2 h1:ozlFUa4X7SzBwvQqnUXIqF991P2afWR2G221y75vJyc=
github.com/grafana/dskit v0.0.0-20240112005349-f30e65d9dee2/go.mod h1:kkWM4WUV230bNG3urVRWPBnSJHs64y/0RmWjftnnn0c=
github.com/grafana/dskit v0.0.0-20240117144322-b9a439dedeb8 h1:6sqXQFpxe/VO2VsBwhdbGd6TGSULFf9Mpzij7zXQ66o=
github.com/grafana/dskit v0.0.0-20240117144322-b9a439dedeb8/go.mod h1:x5DMwyr1kyirtHOxoFSZ7RnyOgHdGh03ZruupdPetQM=
github.com/grafana/e2e v0.1.1 h1:/b6xcv5BtoBnx8cZnCiey9DbjEc8z7gXHO5edoeRYxc=
github.com/grafana/e2e v0.1.1/go.mod h1:RpNLgae5VT+BUHvPE+/zSypmOXKwEu4t+tnEMS1ATaE=
github.com/grafana/goautoneg v0.0.0-20231010094147-47ce5e72a9ae h1:Yxbw9jKGJVC6qAK5Ubzzb/qZwM6rRMMqaDc/d4Vp3pM=
Expand Down Expand Up @@ -904,8 +904,6 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
github.com/sony/gobreaker v0.5.0 h1:dRCvqm0P490vZPmy7ppEk2qCnCieBooFJ+YoXGYB+yg=
github.com/sony/gobreaker v0.5.0/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down Expand Up @@ -1131,7 +1129,6 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand Down
18 changes: 8 additions & 10 deletions pkg/storegateway/indexcache/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ func NewRemoteIndexCache(logger log.Logger, remote cache.RemoteCacheClient, reg
}

// set stores a value for the given key in the remote cache.
func (c *RemoteIndexCache) set(typ string, key string, val []byte) {
if err := c.remote.SetAsync(key, val, remoteDefaultTTL); err != nil {
level.Error(c.logger).Log("msg", "failed to set item in remote cache", "type", typ, "err", err)
}
func (c *RemoteIndexCache) set(key string, val []byte) {
c.remote.SetAsync(key, val, remoteDefaultTTL)
}

// get retrieves a single value from the remote cache, returned bool value indicates whether the value was found or not.
Expand All @@ -95,7 +93,7 @@ func (c *RemoteIndexCache) get(ctx context.Context, typ string, key string) ([]b
// The function enqueues the request and returns immediately: the entry will be
// asynchronously stored in the cache.
func (c *RemoteIndexCache) StorePostings(userID string, blockID ulid.ULID, l labels.Label, v []byte) {
c.set(cacheTypePostings, postingsCacheKey(userID, blockID.String(), l), v)
c.set(postingsCacheKey(userID, blockID.String(), l), v)
}

// FetchMultiPostings fetches multiple postings - each identified by a label.
Expand Down Expand Up @@ -201,7 +199,7 @@ func postingsCacheKeyLabelID(l labels.Label) (out [blake2b.Size256]byte, outLen
// The function enqueues the request and returns immediately: the entry will be
// asynchronously stored in the cache.
func (c *RemoteIndexCache) StoreSeriesForRef(userID string, blockID ulid.ULID, id storage.SeriesRef, v []byte) {
c.set(cacheTypeSeriesForRef, seriesForRefCacheKey(userID, blockID, id), v)
c.set(seriesForRefCacheKey(userID, blockID, id), v)
}

// FetchMultiSeriesForRefs fetches multiple series - each identified by ID - from the cache
Expand Down Expand Up @@ -264,7 +262,7 @@ func seriesForRefCacheKey(userID string, blockID ulid.ULID, id storage.SeriesRef

// StoreExpandedPostings stores the encoded result of ExpandedPostings for specified matchers identified by the provided LabelMatchersKey.
func (c *RemoteIndexCache) StoreExpandedPostings(userID string, blockID ulid.ULID, lmKey LabelMatchersKey, postingsSelectionStrategy string, v []byte) {
c.set(cacheTypeExpandedPostings, expandedPostingsCacheKey(userID, blockID, lmKey, postingsSelectionStrategy), v)
c.set(expandedPostingsCacheKey(userID, blockID, lmKey, postingsSelectionStrategy), v)
}

// FetchExpandedPostings fetches the encoded result of ExpandedPostings for specified matchers identified by the provided LabelMatchersKey.
Expand All @@ -279,7 +277,7 @@ func expandedPostingsCacheKey(userID string, blockID ulid.ULID, lmKey LabelMatch

// StoreSeriesForPostings stores a series set for the provided postings.
func (c *RemoteIndexCache) StoreSeriesForPostings(userID string, blockID ulid.ULID, shard *sharding.ShardSelector, postingsKey PostingsKey, v []byte) {
c.set(cacheTypeSeriesForPostings, seriesForPostingsCacheKey(userID, blockID, shard, postingsKey), v)
c.set(seriesForPostingsCacheKey(userID, blockID, shard, postingsKey), v)
}

// FetchSeriesForPostings fetches a series set for the provided postings.
Expand All @@ -300,7 +298,7 @@ func seriesForPostingsCacheKey(userID string, blockID ulid.ULID, shard *sharding

// StoreLabelNames stores the result of a LabelNames() call.
func (c *RemoteIndexCache) StoreLabelNames(userID string, blockID ulid.ULID, matchersKey LabelMatchersKey, v []byte) {
c.set(cacheTypeLabelNames, labelNamesCacheKey(userID, blockID, matchersKey), v)
c.set(labelNamesCacheKey(userID, blockID, matchersKey), v)
}

// FetchLabelNames fetches the result of a LabelNames() call.
Expand All @@ -315,7 +313,7 @@ func labelNamesCacheKey(userID string, blockID ulid.ULID, matchersKey LabelMatch

// StoreLabelValues stores the result of a LabelValues() call.
func (c *RemoteIndexCache) StoreLabelValues(userID string, blockID ulid.ULID, labelName string, matchersKey LabelMatchersKey, v []byte) {
c.set(cacheTypeLabelValues, labelValuesCacheKey(userID, blockID, labelName, matchersKey), v)
c.set(labelValuesCacheKey(userID, blockID, labelName, matchersKey), v)
}

// FetchLabelValues fetches the result of a LabelValues() call.
Expand Down
8 changes: 6 additions & 2 deletions pkg/storegateway/indexcache/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,10 +934,14 @@ func (c *mockedRemoteCacheClient) GetMulti(_ context.Context, keys []string, _ .
return hits
}

func (c *mockedRemoteCacheClient) SetAsync(key string, value []byte, _ time.Duration) error {
func (c *mockedRemoteCacheClient) SetAsync(key string, value []byte, _ time.Duration) {
c.cache[key] = value
}

return nil
func (c *mockedRemoteCacheClient) SetMultiAsync(data map[string][]byte, _ time.Duration) {
for key, value := range data {
c.cache[key] = value
}
}

func (c *mockedRemoteCacheClient) Delete(_ context.Context, key string) error {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions vendor/github.com/grafana/dskit/cache/cache.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions vendor/github.com/grafana/dskit/cache/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions vendor/github.com/grafana/dskit/cache/memcached_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions vendor/github.com/grafana/dskit/cache/redis_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 1 addition & 17 deletions vendor/github.com/grafana/dskit/cache/remote_cache.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a56442d

Please sign in to comment.