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: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ check-protos: clean-protos protos
@git diff --exit-code -- $(PROTO_GOS)

modernize:
GOTOOLCHAIN=auto go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.21.0 -fix ./...
GOTOOLCHAIN=auto go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.22.0 -fix ./...

# Generates the config file documentation.
doc: clean-doc
Expand Down
5 changes: 3 additions & 2 deletions integration/e2e/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2e
import (
"fmt"
"os"
"slices"
"strings"
"sync"

Expand Down Expand Up @@ -151,14 +152,14 @@ func (s *Scenario) shutdown() {
// Kill the services in parallel. We still iterate in reverse order
// to respect service dependencies, but we kill them concurrently.
var wg sync.WaitGroup
for i := len(s.services) - 1; i >= 0; i-- {
for _, v := range slices.Backward(s.services) {
wg.Add(1)
go func(service Service) {
defer wg.Done()
if err := service.Kill(); err != nil {
logger.Log("Unable to kill service", service.Name(), ":", err.Error())
}
}(s.services[i])
}(v)
}
wg.Wait()

Expand Down
2 changes: 1 addition & 1 deletion pkg/cortex/modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func checkSensitiveFields(t reflect.Type, prefix string, pattern *regexp.Regexp,
path := prefix + f.Name

yamlTag := f.Tag.Get("yaml")
yamlName := strings.Split(yamlTag, ",")[0]
yamlName, _, _ := strings.Cut(yamlTag, ",")

if pattern.MatchString(yamlName) && f.Type.Kind() == reflect.String {
*violations = append(*violations, path+" (yaml:\""+yamlName+"\")")
Expand Down
9 changes: 5 additions & 4 deletions pkg/querier/blocks_finder_bucket_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"maps"
"path"
"path/filepath"
"slices"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -133,13 +134,13 @@ func (d *BucketScanBlocksFinder) GetBlocks(_ context.Context, userID string, min
// Given we do expect the large majority of queries to have a time range close
// to "now", we're going to find matching blocks iterating the list in reverse order.
var matchingMetas bucketindex.Blocks
for i := len(userMetas) - 1; i >= 0; i-- {
if userMetas[i].Within(minT, maxT) {
matchingMetas = append(matchingMetas, userMetas[i])
for _, userMeta := range slices.Backward(userMetas) {
if userMeta.Within(minT, maxT) {
matchingMetas = append(matchingMetas, userMeta)
}

// We can safely break the loop because metas are sorted by MaxTime.
if userMetas[i].MaxTime <= minT {
if userMeta.MaxTime <= minT {
break
}
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/querier/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ type QueryStats struct {

// Phase tracking fields for timeout classification.
// Stored as UnixNano int64 for atomic operations.
queryStart int64 // nanosecond timestamp when query began
queryEnd int64 // nanosecond timestamp when query finished
queueJoinTime int64 // nanosecond timestamp when request entered scheduler queue
queueLeaveTime int64 // nanosecond timestamp when request left scheduler queue
queryStart atomic.Int64 // nanosecond timestamp when query began
queryEnd atomic.Int64 // nanosecond timestamp when query finished
queueJoinTime atomic.Int64 // nanosecond timestamp when request entered scheduler queue
queueLeaveTime atomic.Int64 // nanosecond timestamp when request left scheduler queue
}

// ContextWithEmptyStats returns a context with empty stats.
Expand Down Expand Up @@ -326,7 +326,7 @@ func (s *QueryStats) SetQueryStart(t time.Time) {
return
}

atomic.StoreInt64(&s.queryStart, t.UnixNano())
s.queryStart.Store(t.UnixNano())
}

// LoadQueryStart returns the query start time.
Expand All @@ -335,7 +335,7 @@ func (s *QueryStats) LoadQueryStart() time.Time {
return time.Time{}
}

ns := atomic.LoadInt64(&s.queryStart)
ns := s.queryStart.Load()
if ns == 0 {
return time.Time{}
}
Expand All @@ -348,7 +348,7 @@ func (s *QueryStats) SetQueryEnd(t time.Time) {
return
}

atomic.StoreInt64(&s.queryEnd, t.UnixNano())
s.queryEnd.Store(t.UnixNano())
}

// LoadQueryEnd returns the query end time.
Expand All @@ -357,7 +357,7 @@ func (s *QueryStats) LoadQueryEnd() time.Time {
return time.Time{}
}

ns := atomic.LoadInt64(&s.queryEnd)
ns := s.queryEnd.Load()
if ns == 0 {
return time.Time{}
}
Expand All @@ -370,7 +370,7 @@ func (s *QueryStats) SetQueueJoinTime(t time.Time) {
return
}

atomic.StoreInt64(&s.queueJoinTime, t.UnixNano())
s.queueJoinTime.Store(t.UnixNano())
}

// LoadQueueJoinTime returns the queue join time.
Expand All @@ -379,7 +379,7 @@ func (s *QueryStats) LoadQueueJoinTime() time.Time {
return time.Time{}
}

ns := atomic.LoadInt64(&s.queueJoinTime)
ns := s.queueJoinTime.Load()
if ns == 0 {
return time.Time{}
}
Expand All @@ -392,7 +392,7 @@ func (s *QueryStats) SetQueueLeaveTime(t time.Time) {
return
}

atomic.StoreInt64(&s.queueLeaveTime, t.UnixNano())
s.queueLeaveTime.Store(t.UnixNano())
}

// LoadQueueLeaveTime returns the queue leave time.
Expand All @@ -401,7 +401,7 @@ func (s *QueryStats) LoadQueueLeaveTime() time.Time {
return time.Time{}
}

ns := atomic.LoadInt64(&s.queueLeaveTime)
ns := s.queueLeaveTime.Load()
if ns == 0 {
return time.Time{}
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/querier/tripperware/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"io"
"net/http"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -99,8 +100,8 @@ type roundTripper struct {
// ie Merge(f,g,h).Wrap(handler) == f.Wrap(g.Wrap(h.Wrap(handler)))
func MergeMiddlewares(middleware ...Middleware) Middleware {
return MiddlewareFunc(func(next Handler) Handler {
for i := len(middleware) - 1; i >= 0; i-- {
next = middleware[i].Wrap(next)
for _, m := range slices.Backward(middleware) {
next = m.Wrap(next)
}
return next
})
Expand Down
5 changes: 3 additions & 2 deletions pkg/util/grpcclient/unwrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grpcclient
import (
"context"
"errors"
"slices"
"testing"

otgrpc "github.com/opentracing-contrib/go-grpc"
Expand Down Expand Up @@ -66,12 +67,12 @@ func TestUnwrapErrorStreamClientInterceptor(t *testing.T) {

// Chain the interceptors
chainedStreamer := mockStreamer
for i := len(interceptors) - 1; i >= 0; i-- {
for _, interceptor := range slices.Backward(interceptors) {
chainedStreamer = func(interceptor grpc.StreamClientInterceptor, next grpc.Streamer) grpc.Streamer {
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) {
return interceptor(ctx, desc, cc, method, next, opts...)
}
}(interceptors[i], chainedStreamer)
}(interceptor, chainedStreamer)
}

// Call the chained streamer
Expand Down
Loading