Skip to content

Commit 17d82f1

Browse files
fix lint errors
1 parent dbacd63 commit 17d82f1

File tree

9 files changed

+32
-19
lines changed

9 files changed

+32
-19
lines changed

.bingo/ginkgo.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.22.5
3+
go 1.22
44

55
require github.com/onsi/ginkgo/v2 v2.20.2 // ginkgo

.bingo/golangci-lint.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.22.5
3+
go 1.22
44

55
require github.com/golangci/golangci-lint v1.61.0 // cmd/golangci-lint

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
jobs:
44
lint:
55
docker:
6-
- image: golang:1.20
6+
- image: golang:1.22
77
working_directory: ~/loki-benchmarks
88
steps:
99
- checkout

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
)
1919

2020
require (
21+
github.com/ViaQ/logerr/v2 v2.1.0 // indirect
2122
github.com/beorn7/perks v1.0.1 // indirect
2223
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2324
github.com/davecgh/go-spew v1.1.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/ViaQ/logerr/v2 v2.1.0 h1:8WwzuNa1x+a6tRUl+6sFel83A/QxlFBUaFW2FyG2zzY=
2+
github.com/ViaQ/logerr/v2 v2.1.0/go.mod h1:/qoWLm3YG40Sv5u75s4fvzjZ5p36xINzaxU2L+DJ9uw=
13
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
24
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
35
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=

internal/loadclient/deployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
appsv1 "k8s.io/api/apps/v1"
88
corev1 "k8s.io/api/core/v1"
99
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10-
"k8s.io/utils/pointer"
10+
"k8s.io/utils/ptr"
1111
"sigs.k8s.io/controller-runtime/pkg/client"
1212
)
1313

@@ -60,7 +60,7 @@ func NewLoadClientDeployment(
6060
Labels: labels,
6161
},
6262
Spec: appsv1.DeploymentSpec{
63-
Replicas: pointer.Int32(replicas),
63+
Replicas: ptr.To(replicas),
6464
Selector: &metav1.LabelSelector{
6565
MatchLabels: labels,
6666
},

internal/metrics/client.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package metrics
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"time"
78

9+
"github.com/ViaQ/logerr/v2/kverrors"
810
"github.com/onsi/gomega/gmeasure"
911
"github.com/prometheus/client_golang/api"
1012
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
@@ -19,6 +21,11 @@ const (
1921
ReadRequestPath
2022
)
2123

24+
var (
25+
errNilExperiment = errors.New("error measuring experiment: nil experiment")
26+
errUnknownPath = errors.New("error unknown path specified")
27+
)
28+
2229
type Client struct {
2330
api v1.API
2431
timeout time.Duration
@@ -39,20 +46,20 @@ func NewClient(url, token string, timeout time.Duration, cadvisorEnabled bool) (
3946
}
4047

4148
if err := httpConfig.Validate(); err != nil {
42-
return nil, fmt.Errorf("failed to validate httpConfig: %w", err)
49+
return nil, kverrors.Wrap(err, "failed to validate httpConfig")
4350
}
4451

4552
rt, err := config.NewRoundTripperFromConfig(httpConfig, "benchmarks-metrics")
4653
if err != nil {
47-
return nil, fmt.Errorf("failed creating prometheus configuration: %w", err)
54+
return nil, kverrors.Wrap(err, "failed creating prometheus configuration")
4855
}
4956

5057
pc, err := api.NewClient(api.Config{
5158
Address: url,
5259
RoundTripper: rt,
5360
})
5461
if err != nil {
55-
return nil, fmt.Errorf("failed creating prometheus client: %w", err)
62+
return nil, kverrors.Wrap(err, "failed creating prometheus client")
5663
}
5764

5865
return &Client{
@@ -64,12 +71,12 @@ func NewClient(url, token string, timeout time.Duration, cadvisorEnabled bool) (
6471

6572
func (c *Client) Measure(e *gmeasure.Experiment, data Measurement) error {
6673
if e == nil {
67-
return fmt.Errorf("error measuring experiment: nil experiment")
74+
return errNilExperiment
6875
}
6976

7077
value, err := c.executeScalarQuery(data.Query)
7178
if err != nil {
72-
return fmt.Errorf("error measuring experiment: %s", err)
79+
return kverrors.Wrap(err, "error measuring experiment")
7380
}
7481

7582
e.RecordValue(data.Name, value, data.Unit, data.Annotation, gmeasure.Precision(4))
@@ -89,7 +96,7 @@ func (c *Client) MeasureHTTPRequestMetrics(
8996
case ReadRequestPath:
9097
return c.measureCommonRequestMetrics(e, job, HTTPGetMethod, HTTPQueryRangeRoute, HTTPReadPathRoutes, sampleRange, annotation)
9198
default:
92-
return fmt.Errorf("error unknown path specified: %d", path)
99+
return kverrors.Wrap(errUnknownPath, "path", path)
93100
}
94101
}
95102

@@ -106,7 +113,7 @@ func (c *Client) MeasureGRPCRequestMetrics(
106113
case ReadRequestPath:
107114
return c.measureCommonRequestMetrics(e, job, GRPCMethod, GRPCQuerySampleRoute, GRPCReadPathRoutes, sampleRange, annotation)
108115
default:
109-
return fmt.Errorf("error unknown path specified: %d", path)
116+
return kverrors.Wrap(errUnknownPath, "path", path)
110117
}
111118
}
112119

@@ -122,7 +129,7 @@ func (c *Client) MeasureIndexRequestMetrics(
122129
case ReadRequestPath:
123130
return c.Measure(e, RequestIndexRequestRate(IndexReadName, job, ReadOperation, "2.*", sampleRange))
124131
default:
125-
return fmt.Errorf("error unknown path specified: %d", path)
132+
return kverrors.Wrap(errUnknownPath, "path", path)
126133
}
127134
}
128135

@@ -225,7 +232,7 @@ func (c *Client) executeScalarQuery(query string) (float64, error) {
225232

226233
res, _, err := c.api.Query(ctx, query, time.Now())
227234
if err != nil {
228-
return 0.0, fmt.Errorf("failed executing query %q: %w", query, err)
235+
return 0.0, kverrors.Wrap(err, "failed executing query", "query", query)
229236
}
230237

231238
switch res.Type() {
@@ -239,7 +246,7 @@ func (c *Client) executeScalarQuery(query string) (float64, error) {
239246
}
240247
return float64(vec[0].Value), nil
241248
default:
242-
return 0.0, fmt.Errorf("failed to parse result for query: %s", query)
249+
return 0.0, kverrors.Wrap(err, "failed to parse result for query", "query", query)
243250
}
244251
}
245252

internal/querier/deployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
appsv1 "k8s.io/api/apps/v1"
99
corev1 "k8s.io/api/core/v1"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11-
"k8s.io/utils/pointer"
11+
"k8s.io/utils/ptr"
1212
"sigs.k8s.io/controller-runtime/pkg/client"
1313
)
1414

@@ -90,7 +90,7 @@ func NewLogCLIDeployment(
9090
Labels: labels,
9191
},
9292
Spec: appsv1.DeploymentSpec{
93-
Replicas: pointer.Int32(replicas),
93+
Replicas: ptr.To(replicas),
9494
Selector: &metav1.LabelSelector{
9595
MatchLabels: labels,
9696
},

internal/utils/wait.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import (
1212
)
1313

1414
func WaitForReadyDeployment(c client.Client, o client.Object, retry, timeout time.Duration) error {
15-
return wait.Poll(retry, timeout, func() (done bool, err error) {
15+
ctx, cancel := context.WithTimeout(context.Background(), timeout)
16+
defer cancel()
17+
18+
return wait.PollUntilContextTimeout(ctx, retry, timeout, true, func(ctx context.Context) (done bool, err error) {
1619
dpl := &appsv1.Deployment{}
1720
key := client.ObjectKeyFromObject(o)
1821

19-
err = c.Get(context.TODO(), key, dpl)
22+
err = c.Get(ctx, key, dpl)
2023
if err != nil {
2124
if errors.IsNotFound(err) {
2225
return false, nil

0 commit comments

Comments
 (0)