Skip to content

Commit f34e7f6

Browse files
authored
Fixed the rest of the lint errors and updating the linters to match what is typically used in other sub-projects (#134)
1 parent 0a100c6 commit f34e7f6

File tree

19 files changed

+63
-76
lines changed

19 files changed

+63
-76
lines changed

.golangci.yml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,41 @@ run:
22
timeout: 5m
33
allow-parallel-runners: true
44

5+
# Settings related to issues
56
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "internal/*"
16-
linters:
17-
- dupl
18-
- lll
7+
# Which dirs to exclude: issues from them won't be reported
8+
exclude-dirs:
9+
- bin
1910
linters:
2011
disable-all: true
2112
enable:
22-
- dupl
23-
- errcheck
2413
- copyloopvar
14+
- dupword
15+
- durationcheck
16+
- fatcontext
17+
- gci
2518
- ginkgolinter
19+
- gocritic
20+
- govet
21+
- loggercheck
22+
- misspell
23+
- perfsprint
24+
- revive
25+
- unconvert
26+
- makezero
27+
- errcheck
2628
- goconst
2729
- gocyclo
2830
- gofmt
2931
- goimports
3032
- gosimple
31-
- govet
3233
- ineffassign
33-
- lll
34-
- misspell
3534
- nakedret
3635
- prealloc
37-
- revive
38-
- staticcheck
3936
- typecheck
40-
- unconvert
4137
- unparam
4238
- unused
43-
39+
4440
linters-settings:
4541
revive:
4642
rules:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ ci-lint: golangci-lint
122122
$(GOLANGCI_LINT) run --timeout 15m0s
123123

124124
.PHONY: verify
125-
verify: vet fmt-verify manifests generate ## ci-lint add back when all lint errors are fixed
125+
verify: vet fmt-verify manifests generate ci-lint
126126
git --no-pager diff --exit-code config api client-go
127127

128128
##@ Build

api/v1alpha1/inferencemodel_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type InferenceModelSpec struct {
4141
// The name of the model as the users set in the "model" parameter in the requests.
4242
// The name should be unique among the workloads that reference the same backend pool.
4343
// This is the parameter that will be used to match the request with. In the future, we may
44-
// allow to match on other request parameters. The other approach to support matching on
44+
// allow to match on other request parameters. The other approach to support matching
4545
// on other request parameters is to use a different ModelName per HTTPFilter.
4646
// Names can be reserved without implementing an actual model in the pool.
4747
// This can be done by specifying a target model and setting the weight to zero,

config/crd/bases/inference.networking.x-k8s.io_inferencemodels.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ spec:
6868
The name of the model as the users set in the "model" parameter in the requests.
6969
The name should be unique among the workloads that reference the same backend pool.
7070
This is the parameter that will be used to match the request with. In the future, we may
71-
allow to match on other request parameters. The other approach to support matching on
71+
allow to match on other request parameters. The other approach to support matching
7272
on other request parameters is to use a different ModelName per HTTPFilter.
7373
Names can be reserved without implementing an actual model in the pool.
7474
This can be done by specifying a target model and setting the weight to zero,

pkg/ext-proc/backend/datastore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package backend
22

33
import (
4-
"fmt"
4+
"errors"
55
"math/rand"
66
"sync"
77

@@ -53,7 +53,7 @@ func (ds *K8sDatastore) getInferencePool() (*v1alpha1.InferencePool, error) {
5353
ds.poolMu.RLock()
5454
defer ds.poolMu.RUnlock()
5555
if ds.inferencePool == nil {
56-
return nil, fmt.Errorf("InferencePool hasn't been initialized yet")
56+
return nil, errors.New("InferencePool hasn't been initialized yet")
5757
}
5858
return ds.inferencePool, nil
5959
}

pkg/ext-proc/backend/endpointslice_reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package backend
22

33
import (
44
"context"
5-
"fmt"
5+
"strconv"
66

77
"inference.networking.x-k8s.io/llm-instance-gateway/api/v1alpha1"
88
discoveryv1 "k8s.io/api/discovery/v1"
@@ -57,7 +57,7 @@ func (c *EndpointSliceReconciler) updateDatastore(
5757
if c.validPod(endpoint) {
5858
pod := Pod{
5959
Name: endpoint.TargetRef.Name,
60-
Address: endpoint.Addresses[0] + ":" + fmt.Sprint(inferencePool.Spec.TargetPortNumber),
60+
Address: endpoint.Addresses[0] + ":" + strconv.Itoa(int(inferencePool.Spec.TargetPortNumber)),
6161
}
6262
podMap[pod] = true
6363
c.Datastore.pods.Store(pod, true)

pkg/ext-proc/backend/inferencepool_reconciler.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ package backend
33
import (
44
"context"
55

6-
"sigs.k8s.io/controller-runtime/pkg/client"
7-
86
"inference.networking.x-k8s.io/llm-instance-gateway/api/v1alpha1"
97
"k8s.io/apimachinery/pkg/runtime"
108
"k8s.io/client-go/tools/record"
119
"k8s.io/klog/v2"
1210
ctrl "sigs.k8s.io/controller-runtime"
11+
"sigs.k8s.io/controller-runtime/pkg/client"
1312
)
1413

1514
// InferencePoolReconciler utilizes the controller runtime to reconcile Instance Gateway resources

pkg/ext-proc/backend/vllm/metrics_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package vllm
22

33
import (
4-
"fmt"
4+
"errors"
55
"testing"
66

7-
"inference.networking.x-k8s.io/llm-instance-gateway/pkg/ext-proc/backend"
8-
97
dto "github.com/prometheus/client_model/go"
108
"github.com/stretchr/testify/assert"
119
"google.golang.org/protobuf/proto"
10+
"inference.networking.x-k8s.io/llm-instance-gateway/pkg/ext-proc/backend"
1211
)
1312

1413
func TestPromToPodMetrics(t *testing.T) {
@@ -215,7 +214,7 @@ func TestPromToPodMetrics(t *testing.T) {
215214
MaxActiveModels: 0,
216215
},
217216
initialPodMetrics: &backend.PodMetrics{},
218-
expectedErr: fmt.Errorf("strconv.Atoi: parsing '2a': invalid syntax"),
217+
expectedErr: errors.New("strconv.Atoi: parsing '2a': invalid syntax"),
219218
},
220219
}
221220
for _, tc := range testCases {

pkg/ext-proc/handlers/request.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package handlers
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"strconv"
78

89
configPb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
910
extProcPb "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
10-
klog "k8s.io/klog/v2"
11-
1211
"inference.networking.x-k8s.io/llm-instance-gateway/pkg/ext-proc/backend"
1312
"inference.networking.x-k8s.io/llm-instance-gateway/pkg/ext-proc/scheduling"
13+
klog "k8s.io/klog/v2"
1414
)
1515

1616
// HandleRequestBody handles body of the request to the backend server, such as parsing the "model"
@@ -31,7 +31,7 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
3131
// Resolve target models.
3232
model, ok := rb["model"].(string)
3333
if !ok {
34-
return nil, fmt.Errorf("model not found in request")
34+
return nil, errors.New("model not found in request")
3535
}
3636
klog.V(3).Infof("Model requested: %v", model)
3737
modelName := model
@@ -87,7 +87,7 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
8787
},
8888
},
8989
// We need to update the content length header if the body is mutated, see Envoy doc:
90-
// https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ext_proc/v3/processing_mode.proto#enum-extensions-filters-http-ext-proc-v3-processingmode-bodysendmode
90+
// https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ext_proc/v3/processing_mode.proto
9191
{
9292
Header: &configPb.HeaderValue{
9393
Key: "Content-Length",

pkg/ext-proc/handlers/server.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import (
77
envoyTypePb "github.com/envoyproxy/go-control-plane/envoy/type/v3"
88
"google.golang.org/grpc/codes"
99
"google.golang.org/grpc/status"
10-
klog "k8s.io/klog/v2"
11-
1210
"inference.networking.x-k8s.io/llm-instance-gateway/api/v1alpha1"
1311
"inference.networking.x-k8s.io/llm-instance-gateway/pkg/ext-proc/backend"
1412
"inference.networking.x-k8s.io/llm-instance-gateway/pkg/ext-proc/scheduling"
13+
klog "k8s.io/klog/v2"
1514
)
1615

1716
func NewServer(pp PodProvider, scheduler Scheduler, targetPodHeader string, datastore ModelDataStore) *Server {
@@ -73,7 +72,7 @@ func (s *Server) Process(srv extProcPb.ExternalProcessor_ProcessServer) error {
7372
return status.Errorf(codes.Unknown, "cannot receive stream request: %v", err)
7473
}
7574

76-
resp := &extProcPb.ProcessingResponse{}
75+
var resp *extProcPb.ProcessingResponse
7776
switch v := req.Request.(type) {
7877
case *extProcPb.ProcessingRequest_RequestHeaders:
7978
resp = HandleRequestHeaders(reqCtx, req)

0 commit comments

Comments
 (0)