From 611481b6cfaff4b7454ea655e3543026778a9927 Mon Sep 17 00:00:00 2001 From: Charles Korn Date: Tue, 15 Aug 2023 16:19:03 +1000 Subject: [PATCH] Upgrade dskit (#10249) --- docs/sources/configure/_index.md | 8 ++++++++ go.mod | 2 +- go.sum | 4 ++-- pkg/storage/chunk/chunk.go | 15 ++++++++------- pkg/storage/chunk/interface.go | 12 ++++++------ .../github.com/grafana/dskit/backoff/backoff.go | 5 ++++- vendor/github.com/grafana/dskit/errors/error.go | 10 ---------- .../github.com/grafana/dskit/grpcutil/util.go | 17 ----------------- .../github.com/grafana/dskit/server/server.go | 6 +++--- vendor/github.com/grafana/dskit/user/id.go | 16 +++++++--------- vendor/modules.txt | 3 +-- 11 files changed, 40 insertions(+), 58 deletions(-) delete mode 100644 vendor/github.com/grafana/dskit/errors/error.go delete mode 100644 vendor/github.com/grafana/dskit/grpcutil/util.go diff --git a/docs/sources/configure/_index.md b/docs/sources/configure/_index.md index 4249d1ae03ccc..f23d6eea728f7 100644 --- a/docs/sources/configure/_index.md +++ b/docs/sources/configure/_index.md @@ -265,10 +265,14 @@ Configures the `server` of the launched module(s). [tls_min_version: | default = ""] http_tls_config: + # Server TLS certificate. This configuration parameter is YAML only. [cert: | default = ""] + # Server TLS key. This configuration parameter is YAML only. [key: | default = ""] + # Root certificate authority used to verify client certificates. This + # configuration parameter is YAML only. [client_ca: | default = ""] # HTTP server cert path. @@ -288,10 +292,14 @@ http_tls_config: [client_ca_file: | default = ""] grpc_tls_config: + # Server TLS certificate. This configuration parameter is YAML only. [cert: | default = ""] + # Server TLS key. This configuration parameter is YAML only. [key: | default = ""] + # Root certificate authority used to verify client certificates. This + # configuration parameter is YAML only. [client_ca: | default = ""] # GRPC TLS server cert path. diff --git a/go.mod b/go.mod index 86ca4214c6904..a0b610c6574e9 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 - github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975 + github.com/grafana/dskit v0.0.0-20230814145153-042a71bd637e github.com/grafana/go-gelf/v2 v2.0.1 github.com/grafana/gomemcache v0.0.0-20230316202710-a081dae0aba9 github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd diff --git a/go.sum b/go.sum index 23991bc8425af..4566a60a3a8f9 100644 --- a/go.sum +++ b/go.sum @@ -1073,8 +1073,8 @@ github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw= -github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975 h1:rCBTyr4vKVNh+synt3A3o3jxgcLSk/y958iOdfaIjW0= -github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975/go.mod h1:clB9S8ZI/5NiIMCnRv0rA60xs2y1iyVGmO4E5Z8nueE= +github.com/grafana/dskit v0.0.0-20230814145153-042a71bd637e h1:8u1RKsS5CJeOlbGcuBC8/LyEywI7mPQj3d3Sqk+5hQ8= +github.com/grafana/dskit v0.0.0-20230814145153-042a71bd637e/go.mod h1:SA90oxyODAYOFCW/O1HrS5Zu/zhNzh+yF4D+GoWmBEk= github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak= github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90= github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY= diff --git a/pkg/storage/chunk/chunk.go b/pkg/storage/chunk/chunk.go index 9bf2d1cf0b65b..d316553d72fa6 100644 --- a/pkg/storage/chunk/chunk.go +++ b/pkg/storage/chunk/chunk.go @@ -10,8 +10,9 @@ import ( "sync" "unsafe" + errs "errors" + "github.com/golang/snappy" - errs "github.com/grafana/dskit/errors" jsoniter "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/prometheus/common/model" @@ -20,12 +21,12 @@ import ( "github.com/grafana/loki/pkg/logproto" ) -const ( - ErrInvalidChecksum = errs.Error("invalid chunk checksum") - ErrWrongMetadata = errs.Error("wrong chunk metadata") - ErrMetadataLength = errs.Error("chunk metadata wrong length") - ErrDataLength = errs.Error("chunk data wrong length") - ErrSliceOutOfRange = errs.Error("chunk can't be sliced out of its data range") +var ( + ErrInvalidChecksum = errs.New("invalid chunk checksum") + ErrWrongMetadata = errs.New("wrong chunk metadata") + ErrMetadataLength = errs.New("chunk metadata wrong length") + ErrDataLength = errs.New("chunk data wrong length") + ErrSliceOutOfRange = errs.New("chunk can't be sliced out of its data range") ) var castagnoliTable = crc32.MakeTable(crc32.Castagnoli) diff --git a/pkg/storage/chunk/interface.go b/pkg/storage/chunk/interface.go index 3888472903b65..cf3f619fa8d87 100644 --- a/pkg/storage/chunk/interface.go +++ b/pkg/storage/chunk/interface.go @@ -18,21 +18,21 @@ package chunk import ( "context" + "errors" "io" - errs "github.com/grafana/dskit/errors" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" "github.com/grafana/loki/pkg/util/filter" ) -const ( - // ChunkLen is the length of a chunk in bytes. - ChunkLen = 1024 +// ChunkLen is the length of a chunk in bytes. +const ChunkLen = 1024 - ErrSliceNoDataInRange = errs.Error("chunk has no data for given range to slice") - ErrSliceChunkOverflow = errs.Error("slicing should not overflow a chunk") +var ( + ErrSliceNoDataInRange = errors.New("chunk has no data for given range to slice") + ErrSliceChunkOverflow = errors.New("slicing should not overflow a chunk") ) // Data is the interface for all chunks. Chunks are generally not diff --git a/vendor/github.com/grafana/dskit/backoff/backoff.go b/vendor/github.com/grafana/dskit/backoff/backoff.go index c5d454715974d..7ce5564728488 100644 --- a/vendor/github.com/grafana/dskit/backoff/backoff.go +++ b/vendor/github.com/grafana/dskit/backoff/backoff.go @@ -77,9 +77,12 @@ func (b *Backoff) Wait() { sleepTime := b.NextDelay() if b.Ongoing() { + timer := time.NewTimer(sleepTime) + defer timer.Stop() + select { case <-b.ctx.Done(): - case <-time.After(sleepTime): + case <-timer.C: } } } diff --git a/vendor/github.com/grafana/dskit/errors/error.go b/vendor/github.com/grafana/dskit/errors/error.go deleted file mode 100644 index 1d36f7c39e7cd..0000000000000 --- a/vendor/github.com/grafana/dskit/errors/error.go +++ /dev/null @@ -1,10 +0,0 @@ -// Provenance-includes-location: https://github.com/weaveworks/common/blob/main/errors/error.go -// Provenance-includes-license: Apache-2.0 -// Provenance-includes-copyright: Weaveworks Ltd. - -package errors - -// Error see https://dave.cheney.net/2016/04/07/constant-errors. -type Error string - -func (e Error) Error() string { return string(e) } diff --git a/vendor/github.com/grafana/dskit/grpcutil/util.go b/vendor/github.com/grafana/dskit/grpcutil/util.go deleted file mode 100644 index 858a0e8620894..0000000000000 --- a/vendor/github.com/grafana/dskit/grpcutil/util.go +++ /dev/null @@ -1,17 +0,0 @@ -package grpcutil - -import ( - "github.com/gogo/status" - "google.golang.org/grpc/codes" -) - -// IsGRPCContextCanceled returns whether the input error is a GRPC error wrapping -// the context.Canceled error. -func IsGRPCContextCanceled(err error) bool { - s, ok := status.FromError(err) - if !ok { - return false - } - - return s.Code() == codes.Canceled -} diff --git a/vendor/github.com/grafana/dskit/server/server.go b/vendor/github.com/grafana/dskit/server/server.go index 140b9ec4e5dd0..4cf3b852ef88b 100644 --- a/vendor/github.com/grafana/dskit/server/server.go +++ b/vendor/github.com/grafana/dskit/server/server.go @@ -57,9 +57,9 @@ type SignalHandler interface { // TLSConfig contains TLS parameters for Config. type TLSConfig struct { - TLSCert string `yaml:"cert"` - TLSKey config.Secret `yaml:"key"` - ClientCAsText string `yaml:"client_ca"` + TLSCert string `yaml:"cert" doc:"description=Server TLS certificate. This configuration parameter is YAML only."` + TLSKey config.Secret `yaml:"key" doc:"description=Server TLS key. This configuration parameter is YAML only."` + ClientCAsText string `yaml:"client_ca" doc:"description=Root certificate authority used to verify client certificates. This configuration parameter is YAML only."` TLSCertPath string `yaml:"cert_file"` TLSKeyPath string `yaml:"key_file"` ClientAuth string `yaml:"client_auth_type"` diff --git a/vendor/github.com/grafana/dskit/user/id.go b/vendor/github.com/grafana/dskit/user/id.go index 2396787c28c7e..bafecdce93953 100644 --- a/vendor/github.com/grafana/dskit/user/id.go +++ b/vendor/github.com/grafana/dskit/user/id.go @@ -6,8 +6,7 @@ package user import ( "context" - - "github.com/grafana/dskit/errors" + "errors" ) type contextKey int @@ -19,14 +18,13 @@ const ( ) // Errors that we return -const ( - ErrNoOrgID = errors.Error("no org id") - ErrDifferentOrgIDPresent = errors.Error("different org ID already present") - ErrTooManyOrgIDs = errors.Error("multiple org IDs present") +var ( + ErrNoOrgID = errors.New("no org id") + ErrDifferentOrgIDPresent = errors.New("different org ID already present") + ErrTooManyOrgIDs = errors.New("multiple org IDs present") - ErrNoUserID = errors.Error("no user id") - ErrDifferentUserIDPresent = errors.Error("different user ID already present") - ErrTooManyUserIDs = errors.Error("multiple user IDs present") + ErrNoUserID = errors.New("no user id") + ErrDifferentUserIDPresent = errors.New("different user ID already present") ) // ExtractOrgID gets the org ID from the context. diff --git a/vendor/modules.txt b/vendor/modules.txt index 028a3dcc6141a..b582cb92b9253 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -826,7 +826,7 @@ github.com/gorilla/websocket # github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 ## explicit; go 1.17 github.com/grafana/cloudflare-go -# github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975 +# github.com/grafana/dskit v0.0.0-20230814145153-042a71bd637e ## explicit; go 1.19 github.com/grafana/dskit/aws github.com/grafana/dskit/backoff @@ -835,7 +835,6 @@ github.com/grafana/dskit/crypto/tls github.com/grafana/dskit/dns github.com/grafana/dskit/dns/godns github.com/grafana/dskit/dns/miekgdns -github.com/grafana/dskit/errors github.com/grafana/dskit/flagext github.com/grafana/dskit/grpcclient github.com/grafana/dskit/grpcencoding/snappy