Skip to content

Commit

Permalink
fix lint issues from PR 7804 (#7814)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:
I had enabled auto-merge in PR #7804, but somehow it still merged the PR
without all the checks passing.
This PR fixes the failing lint and tests.
  • Loading branch information
sandeepsukhani authored Nov 30, 2022
1 parent 5dc6056 commit 89d8102
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 27 deletions.
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/cloudflare/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
allFields = append(extendedFields, []string{
"BotScore", "BotScoreSrc", "ClientRequestBytes", "ClientSrcPort", "ClientXRequestedWith", "CacheTieredFill", "EdgeResponseCompressionRatio", "EdgeServerIP", "FirewallMatchesSources",
"FirewallMatchesActions", "FirewallMatchesRuleIDs", "OriginResponseBytes", "OriginResponseTime", "ClientDeviceType", "WAFFlags", "WAFMatchedVar", "EdgeColoID",
"RequestHeaders", "ResponseHeaders",
"RequestHeaders", "ResponseHeaders",
}...)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Test_validateJobName(t *testing.T) {
},
},
},
wantErr: false,
wantErr: false,
expectedJob: "job_1_2_3_4_job",
},
}
Expand Down
1 change: 1 addition & 0 deletions integration/loki_micro_services_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/grafana/loki/integration/client"
"github.com/grafana/loki/integration/cluster"

"github.com/grafana/loki/pkg/storage"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/logql/syntax/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ var tokens = map[string]int{
OpParserTypePattern: PATTERN,

// fmt
OpFmtLabel: LABEL_FMT,
OpFmtLine: LINE_FMT,
OpFmtLabel: LABEL_FMT,
OpFmtLine: LINE_FMT,

// filter functions
OpFilterIP: IP,
Expand Down
3 changes: 2 additions & 1 deletion pkg/logqlmodel/logqlmodel.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package logqlmodel

import (
"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase/definitions"
"github.com/prometheus/prometheus/promql/parser"

"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase/definitions"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logqlmodel/stats"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/logqlmodel/metadata/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"errors"
"testing"

"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase/definitions"
"github.com/stretchr/testify/require"

"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase/definitions"
)

func TestHeaders(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/querier/queryrange/queryrangebase/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ type fakeGenNumberLoader struct {
func (l *fakeGenNumberLoader) GetResultsCacheGenNumber(tenantIDs []string) string {
return l.genNumber
}

func (l *fakeGenNumberLoader) Stop() {}
2 changes: 2 additions & 0 deletions pkg/querier/queryrange/queryrangebase/results_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,3 +1070,5 @@ func newMockCacheGenNumberLoader() CacheGenNumberLoader {
func (mockCacheGenNumberLoader) GetResultsCacheGenNumber(tenantIDs []string) string {
return ""
}

func (l mockCacheGenNumberLoader) Stop() {}
9 changes: 5 additions & 4 deletions pkg/storage/stores/indexshipper/compactor/client/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package client
import (
"context"
"flag"
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/deletion"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/user"

"github.com/grafana/dskit/grpcclient"
deletion_grpc "github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/client/grpc"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/instrument"
"github.com/weaveworks/common/user"
"google.golang.org/grpc"

deletion_grpc "github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/client/grpc"
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/deletion"
)

type GRPCConfig struct {
Expand Down
9 changes: 5 additions & 4 deletions pkg/storage/stores/indexshipper/compactor/client/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/go-kit/log/level"
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/deletion"
"github.com/grafana/loki/pkg/util/log"
"io"
"net/http"
"net/url"
"time"

"github.com/go-kit/log/level"
"github.com/grafana/dskit/crypto/tls"

"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/deletion"
"github.com/grafana/loki/pkg/util/log"
)

const (
Expand Down Expand Up @@ -44,7 +45,7 @@ type compactorHTTPClient struct {

// NewHTTPClient creates a client which talks to compactor over HTTP.
// It uses provided TLS config which creating HTTP client.
func NewHTTPClient(addr string, cfg HTTPConfig) (*compactorHTTPClient, error) {
func NewHTTPClient(addr string, cfg HTTPConfig) (deletion.CompactorClient, error) {
u, err := url.Parse(addr)
if err != nil {
level.Error(log.Logger).Log("msg", "error parsing url", "err", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package deletion

import (
"github.com/go-kit/log/level"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"

"github.com/grafana/loki/pkg/logql/syntax"
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/retention"
"github.com/grafana/loki/pkg/util/filter"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
)

type DeleteRequest struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/go-kit/log/level"

"github.com/grafana/loki/pkg/util/log"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/deletionmode"
)

func server(t *testing.T, ctx context.Context, h *GRPCRequestHandler) (compactor_client_grpc.CompactorClient, func()) {
func server(t *testing.T, h *GRPCRequestHandler) (compactor_client_grpc.CompactorClient, func()) {
buffer := 101024 * 1024
lis := bufconn.Listen(buffer)

Expand All @@ -36,7 +36,7 @@ func server(t *testing.T, ctx context.Context, h *GRPCRequestHandler) (compactor
require.NoError(t, baseServer.Serve(lis))
}()

conn, err := grpc.DialContext(ctx, "",
conn, err := grpc.DialContext(context.Background(), "",
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return lis.Dial()
}), grpc.WithTransportCredentials(insecure.NewCredentials()))
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestGRPCGetDeleteRequests(t *testing.T) {
store := &mockDeleteRequestsStore{}
store.getAllResult = []DeleteRequest{{RequestID: "test-request-1", Status: StatusReceived}, {RequestID: "test-request-2", Status: StatusReceived}}
h := NewGRPCRequestHandler(store, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

ctx, _ := user.InjectIntoGRPCRequest(user.InjectOrgID(context.Background(), user1))
Expand All @@ -95,7 +95,7 @@ func TestGRPCGetDeleteRequests(t *testing.T) {
{RequestID: "test-request-1", CreatedAt: now, StartTime: now.Add(time.Hour), EndTime: now.Add(2 * time.Hour)},
}
h := NewGRPCRequestHandler(store, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

ctx, _ := user.InjectIntoGRPCRequest(user.InjectOrgID(context.Background(), user1))
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestGRPCGetDeleteRequests(t *testing.T) {
{RequestID: "test-request-3", CreatedAt: now.Add(2 * time.Minute), Status: StatusReceived},
}
h := NewGRPCRequestHandler(store, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

ctx, _ := user.InjectIntoGRPCRequest(user.InjectOrgID(context.Background(), user1))
Expand All @@ -144,7 +144,7 @@ func TestGRPCGetDeleteRequests(t *testing.T) {
store := &mockDeleteRequestsStore{}
store.getAllErr = errors.New("something bad")
h := NewGRPCRequestHandler(store, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

ctx, _ := user.InjectIntoGRPCRequest(user.InjectOrgID(context.Background(), user1))
Expand All @@ -161,7 +161,7 @@ func TestGRPCGetDeleteRequests(t *testing.T) {
t.Run("validation", func(t *testing.T) {
t.Run("no org id", func(t *testing.T) {
h := NewGRPCRequestHandler(&mockDeleteRequestsStore{}, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

_, err := grpcClient.GetDeleteRequests(context.Background(), &compactor_client_grpc.GetDeleteRequestsRequest{})
Expand All @@ -177,7 +177,7 @@ func TestGRPCGetCacheGenNumbers(t *testing.T) {
store := &mockDeleteRequestsStore{}
store.genNumber = "123"
h := NewGRPCRequestHandler(store, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

ctx, _ := user.InjectIntoGRPCRequest(user.InjectOrgID(context.Background(), user1))
Expand All @@ -194,7 +194,7 @@ func TestGRPCGetCacheGenNumbers(t *testing.T) {
store := &mockDeleteRequestsStore{}
store.getErr = errors.New("something bad")
h := NewGRPCRequestHandler(store, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

ctx, _ := user.InjectIntoGRPCRequest(user.InjectOrgID(context.Background(), user1))
Expand All @@ -211,7 +211,7 @@ func TestGRPCGetCacheGenNumbers(t *testing.T) {
t.Run("validation", func(t *testing.T) {
t.Run("no org id", func(t *testing.T) {
h := NewGRPCRequestHandler(&mockDeleteRequestsStore{}, &fakeLimits{mode: deletionmode.FilterAndDelete.String()})
grpcClient, closer := server(t, context.Background(), h)
grpcClient, closer := server(t, h)
defer closer()

_, err := grpcClient.GetCacheGenNumbers(context.Background(), &compactor_client_grpc.GetCacheGenNumbersRequest{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewGenNumberLoader(g CacheGenClient, registerer prometheus.Registerer) *Gen
numberGetter: g,
numbers: make(map[string]string),
metrics: newGenLoaderMetrics(registerer),
quit: make(chan struct{}),
}
go l.loop()

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/marshal/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func WriteQueryResponseJSON(v logqlmodel.Result, w io.Writer) error {
defer jsoniter.ConfigFastest.ReturnStream(s)
err := EncodeResult(v, s)
if err != nil {
return fmt.Errorf("could not write JSON repsonse: %w", err)
return fmt.Errorf("could not write JSON response: %w", err)
}
s.WriteRaw("\n")
return s.Flush()
Expand Down

0 comments on commit 89d8102

Please sign in to comment.