diff --git a/Makefile b/Makefile index 2fd3acb0807..0ad17ff459a 100644 --- a/Makefile +++ b/Makefile @@ -275,7 +275,7 @@ mimir-build-image/$(UPTODATE): mimir-build-image/* # All the boiler plate for building golang follows: SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E") BUILD_IN_CONTAINER ?= true -LATEST_BUILD_IMAGE_TAG ?= pr8347-55c99be7fb +LATEST_BUILD_IMAGE_TAG ?= pr8385-000f1b4a10 # TTY is parameterized to allow Google Cloud Builder to run builds, # as it currently disallows TTY devices. This value needs to be overridden diff --git a/mimir-build-image/Dockerfile b/mimir-build-image/Dockerfile index 9680f7df53a..e6613224776 100644 --- a/mimir-build-image/Dockerfile +++ b/mimir-build-image/Dockerfile @@ -35,7 +35,7 @@ RUN GOARCH=$(go env GOARCH) && \ curl -fSL -o "/usr/bin/tk" "https://github.com/grafana/tanka/releases/download/v${TANKA_VERSION}/tk-linux-${GOARCH}" && \ chmod a+x /usr/bin/tk -RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b /usr/bin v1.54.1 +RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b /usr/bin v1.59.1 ENV SKOPEO_VERSION=v1.15.1 RUN git clone --depth 1 --branch ${SKOPEO_VERSION} https://github.com/containers/skopeo /go/src/github.com/containers/skopeo && \ diff --git a/pkg/alertmanager/alertmanager.go b/pkg/alertmanager/alertmanager.go index 87863fcd980..9f15b6cc02c 100644 --- a/pkg/alertmanager/alertmanager.go +++ b/pkg/alertmanager/alertmanager.go @@ -531,10 +531,10 @@ func buildIntegrationsMap(nc []*definition.PostableApiReceiver, tmpl *template.T func buildGrafanaReceiverIntegrations(rcv *definition.PostableApiReceiver, tmpl *template.Template, logger log.Logger) ([]*nfstatus.Integration, error) { loggerFactory := newLoggerFactory(logger) - whFn := func(n alertingReceivers.Metadata) (alertingReceivers.WebhookSender, error) { + whFn := func(alertingReceivers.Metadata) (alertingReceivers.WebhookSender, error) { return NewSender(logger), nil } - emailFn := func(n alertingReceivers.Metadata) (alertingReceivers.EmailSender, error) { + emailFn := func(alertingReceivers.Metadata) (alertingReceivers.EmailSender, error) { return NewSender(logger), nil } diff --git a/pkg/alertmanager/sender_test.go b/pkg/alertmanager/sender_test.go index 7bdf720f6a5..d259aba5aea 100644 --- a/pkg/alertmanager/sender_test.go +++ b/pkg/alertmanager/sender_test.go @@ -81,7 +81,7 @@ func TestSendWebhook(t *testing.T) { testErr := errors.New("test") cmd = alertingReceivers.SendWebhookSettings{ URL: server.URL, - Validation: func(body []byte, statusCode int) error { return testErr }, + Validation: func([]byte, int) error { return testErr }, } require.ErrorIs(t, s.SendWebhook(context.Background(), &cmd), testErr) diff --git a/pkg/distributor/otel_test.go b/pkg/distributor/otel_test.go index 9f58e7b114d..cb59bc19b39 100644 --- a/pkg/distributor/otel_test.go +++ b/pkg/distributor/otel_test.go @@ -318,7 +318,7 @@ func TestHandlerOTLPPush(t *testing.T) { maxMsgSize: 100000, series: sampleSeries, metadata: sampleMetadata, - verifyFunc: func(_ *testing.T, pushReq *Request) error { + verifyFunc: func(*testing.T, *Request) error { return httpgrpc.Errorf(http.StatusTooManyRequests, "go slower") }, responseCode: http.StatusTooManyRequests, diff --git a/pkg/distributor/push_test.go b/pkg/distributor/push_test.go index 42470c54411..896ea0f4b18 100644 --- a/pkg/distributor/push_test.go +++ b/pkg/distributor/push_test.go @@ -902,7 +902,7 @@ func TestOTLPPushHandlerErrorsAreReportedCorrectlyViaHttpgrpc(t *testing.T) { srv, err := dskit_server.New(cfg) require.NoError(t, err) - push := func(ctx context.Context, req *Request) error { + push := func(_ context.Context, req *Request) error { // Trigger conversion of incoming request to WriteRequest. wr, err := req.WriteRequest() if err != nil { diff --git a/pkg/frontend/querymiddleware/remote_read.go b/pkg/frontend/querymiddleware/remote_read.go index 8d85fdb9a56..0552175ec32 100644 --- a/pkg/frontend/querymiddleware/remote_read.go +++ b/pkg/frontend/querymiddleware/remote_read.go @@ -58,7 +58,7 @@ func (r *remoteReadRoundTripper) RoundTrip(req *http.Request) (*http.Response, e if err != nil { return nil, err } - handler := r.middleware.Wrap(HandlerFunc(func(ctx context.Context, req MetricsQueryRequest) (Response, error) { + handler := r.middleware.Wrap(HandlerFunc(func(context.Context, MetricsQueryRequest) (Response, error) { // We do not need to do anything here as this middleware is used for // validation only and previous middlewares would have already returned errors. return nil, nil diff --git a/pkg/frontend/querymiddleware/remote_read_test.go b/pkg/frontend/querymiddleware/remote_read_test.go index fae2d4c5340..aadbbe02f40 100644 --- a/pkg/frontend/querymiddleware/remote_read_test.go +++ b/pkg/frontend/querymiddleware/remote_read_test.go @@ -121,7 +121,7 @@ func TestRemoteReadRoundTripperCallsDownstreamOnAll(t *testing.T) { t.Run(name, func(t *testing.T) { roundTripper := &mockRoundTripper{} countMiddleWareCalls := 0 - middleware := MetricsQueryMiddlewareFunc(func(next MetricsQueryHandler) MetricsQueryHandler { + middleware := MetricsQueryMiddlewareFunc(func(MetricsQueryHandler) MetricsQueryHandler { countMiddleWareCalls++ return tc.handler }) diff --git a/pkg/ingester/ingester_test.go b/pkg/ingester/ingester_test.go index a43331a5e53..0e351539ea2 100644 --- a/pkg/ingester/ingester_test.go +++ b/pkg/ingester/ingester_test.go @@ -242,7 +242,7 @@ func TestIngester_StartReadRequest(t *testing.T) { utilizationLimiter = &fakeUtilizationBasedLimiter{limitingReason: "cpu"} ) - setupIngester := func(tc testCase) *failingIngester { + setupIngester := func(testCase) *failingIngester { cfg := defaultIngesterTestConfig(t) cfg.ReadCircuitBreaker = CircuitBreakerConfig{ Enabled: true, diff --git a/pkg/mimirpb/compat_test.go b/pkg/mimirpb/compat_test.go index 97fa9cced79..cb8d24f2781 100644 --- a/pkg/mimirpb/compat_test.go +++ b/pkg/mimirpb/compat_test.go @@ -8,7 +8,6 @@ package mimirpb import ( stdlibjson "encoding/json" "math" - "reflect" "strconv" "testing" "unsafe" @@ -197,9 +196,7 @@ func TestFromLabelAdaptersToLabelsWithCopy(t *testing.T) { // All strings must be copied. actualValue := actual.Get("hello") - hInputValue := (*reflect.StringHeader)(unsafe.Pointer(&input[0].Value)) - hActualValue := (*reflect.StringHeader)(unsafe.Pointer(&actualValue)) - assert.NotEqual(t, hInputValue.Data, hActualValue.Data) + assert.NotSame(t, unsafe.StringData(input[0].Value), unsafe.StringData(actualValue)) } func BenchmarkFromLabelAdaptersToLabelsWithCopy(b *testing.B) { diff --git a/pkg/mimirpb/timeseries_test.go b/pkg/mimirpb/timeseries_test.go index baa9a0ae5bb..d079f1fd591 100644 --- a/pkg/mimirpb/timeseries_test.go +++ b/pkg/mimirpb/timeseries_test.go @@ -79,6 +79,8 @@ func TestTimeseriesFromPool(t *testing.T) { func TestCopyToYoloString(t *testing.T) { stringByteArray := func(val string) uintptr { + // Ignore deprecation warning for now + //nolint:staticcheck return (*reflect.SliceHeader)(unsafe.Pointer(&val)).Data } @@ -102,6 +104,8 @@ func TestCopyToYoloString(t *testing.T) { assert.Len(t, remainingBuf, 0) // Verify that the remainingBuf is using the same underlying byte array as safeCopy but advanced by the length. + // Ignore deprecation warning for now + //nolint:staticcheck remainingBufArray := (*reflect.SliceHeader)(unsafe.Pointer(&remainingBuf)).Data assert.Equal(t, int(safeCopyByteArray)+len(newBuf), int(remainingBufArray)) } @@ -153,43 +157,79 @@ func TestDeepCopyTimeseries(t *testing.T) { // Check all the slices in the struct to ensure that // none of them refer to the same underlying array. assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Labels)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Labels)).Data, ) assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Samples)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Samples)).Data, ) assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Histograms)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Histograms)).Data, ) assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Exemplars)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Exemplars)).Data, ) for histogramIdx := range src.Histograms { assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Histograms[histogramIdx].NegativeSpans)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Histograms[histogramIdx].NegativeSpans)).Data, ) assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Histograms[histogramIdx].NegativeDeltas)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Histograms[histogramIdx].NegativeDeltas)).Data, ) assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Histograms[histogramIdx].PositiveSpans)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Histograms[histogramIdx].PositiveSpans)).Data, ) assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Histograms[histogramIdx].PositiveDeltas)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Histograms[histogramIdx].PositiveDeltas)).Data, ) } for exemplarIdx := range src.Exemplars { assert.NotEqual(t, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&src.Exemplars[exemplarIdx].Labels)).Data, + // Ignore deprecation warning for now + //nolint:staticcheck (*reflect.SliceHeader)(unsafe.Pointer(&dst.Exemplars[exemplarIdx].Labels)).Data, ) } diff --git a/pkg/querier/api/consistency_test.go b/pkg/querier/api/consistency_test.go index a4f6d39b021..25c5cc0ab7c 100644 --- a/pkg/querier/api/consistency_test.go +++ b/pkg/querier/api/consistency_test.go @@ -34,7 +34,7 @@ func BenchmarkReadConsistencyServerUnaryInterceptor(b *testing.B) { ctx := metadata.NewIncomingContext(context.Background(), md) for n := 0; n < b.N; n++ { - _, _ = ReadConsistencyServerUnaryInterceptor(ctx, nil, nil, func(ctx context.Context, req any) (any, error) { + _, _ = ReadConsistencyServerUnaryInterceptor(ctx, nil, nil, func(context.Context, any) (any, error) { return nil, nil }) } diff --git a/pkg/storegateway/indexcache/cache.go b/pkg/storegateway/indexcache/cache.go index 29822e184f8..b52a9339ab0 100644 --- a/pkg/storegateway/indexcache/cache.go +++ b/pkg/storegateway/indexcache/cache.go @@ -158,7 +158,11 @@ const bytesPerPosting = int(unsafe.Sizeof(storage.SeriesRef(0))) // It casts the memory region of the underlying array to a slice of bytes. The resulting byte slice is only valid as long as the postings slice exists and is unmodified. func unsafeCastPostingsToBytes(postings []storage.SeriesRef) []byte { byteSlice := make([]byte, 0) + // Ignore deprecation warning for now + //nolint:staticcheck slicePtr := (*reflect.SliceHeader)(unsafe.Pointer(&byteSlice)) + // Ignore deprecation warning for now + //nolint:staticcheck slicePtr.Data = (*reflect.SliceHeader)(unsafe.Pointer(&postings)).Data slicePtr.Len = len(postings) * bytesPerPosting slicePtr.Cap = slicePtr.Len diff --git a/pkg/storegateway/indexcache/inmemory.go b/pkg/storegateway/indexcache/inmemory.go index de626385f98..ee900293c4d 100644 --- a/pkg/storegateway/indexcache/inmemory.go +++ b/pkg/storegateway/indexcache/inmemory.go @@ -277,7 +277,11 @@ func (c *InMemoryIndexCache) reset() { func copyString(s string) string { var b []byte + // Ignore deprecation warning for now + //nolint:staticcheck h := (*reflect.SliceHeader)(unsafe.Pointer(&b)) + // Ignore deprecation warning for now + //nolint:staticcheck h.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data h.Len = len(s) h.Cap = len(s) diff --git a/pkg/streamingpromql/functions/common.go b/pkg/streamingpromql/functions/common.go index 3087eec8fa9..45136fab590 100644 --- a/pkg/streamingpromql/functions/common.go +++ b/pkg/streamingpromql/functions/common.go @@ -21,7 +21,7 @@ type InstantVectorFunction func(seriesData types.InstantVectorSeriesData, pool * // floatTransformationFunc is not needed elsewhere, so it is not exported yet func floatTransformationFunc(transform func(f float64) float64) InstantVectorFunction { - return func(seriesData types.InstantVectorSeriesData, pool *pooling.LimitingPool) (types.InstantVectorSeriesData, error) { + return func(seriesData types.InstantVectorSeriesData, _ *pooling.LimitingPool) (types.InstantVectorSeriesData, error) { for i := range seriesData.Floats { seriesData.Floats[i].F = transform(seriesData.Floats[i].F) } diff --git a/pkg/streamingpromql/operators/function_over_instant_vector_test.go b/pkg/streamingpromql/operators/function_over_instant_vector_test.go index eb8653c3ead..2ea06629e57 100644 --- a/pkg/streamingpromql/operators/function_over_instant_vector_test.go +++ b/pkg/streamingpromql/operators/function_over_instant_vector_test.go @@ -30,14 +30,14 @@ func TestFunctionOverInstantVector(t *testing.T) { } metadataFuncCalled := false - mustBeCalledMetadata := func(seriesMetadata []types.SeriesMetadata, pool *pooling.LimitingPool) ([]types.SeriesMetadata, error) { + mustBeCalledMetadata := func(seriesMetadata []types.SeriesMetadata, _ *pooling.LimitingPool) ([]types.SeriesMetadata, error) { require.Equal(t, len(inner.series), len(seriesMetadata)) metadataFuncCalled = true return nil, nil } seriesDataFuncCalledTimes := 0 - mustBeCalledSeriesData := func(seriesData types.InstantVectorSeriesData, pool *pooling.LimitingPool) (types.InstantVectorSeriesData, error) { + mustBeCalledSeriesData := func(types.InstantVectorSeriesData, *pooling.LimitingPool) (types.InstantVectorSeriesData, error) { seriesDataFuncCalledTimes++ return types.InstantVectorSeriesData{}, nil }