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
59 changes: 36 additions & 23 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
version: "2"
run:
timeout: 5m
allow-parallel-runners: true

# Settings related to issues
issues:
# Which dirs to exclude: issues from them won't be reported
exclude-dirs:
- bin
linters:
disable-all: true
default: none
enable:
- copyloopvar
- dupword
- durationcheck
- errcheck
- fatcontext
- ginkgolinter
- goconst
- gocritic
- govet
- ineffassign
- loggercheck
- makezero
- misspell
- nakedret
- perfsprint
- prealloc
- revive
- staticcheck
- unconvert
- makezero
- errcheck
- goconst
- gofmt
- goimports
- gosimple
- ineffassign
- nakedret
- prealloc
- typecheck
- unparam
- unused

linters-settings:
revive:
rules:
- name: comment-spacings
settings:
revive:
rules:
- name: comment-spacings
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- bin
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- bin
- third_party$
- builtin$
- examples$
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ test-e2e: ## Run end-to-end tests against an existing Kubernetes cluster.

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT) run
$(GOLANGCI_LINT) run --timeout 5m

.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
Expand Down Expand Up @@ -373,7 +373,7 @@ GCI = $(LOCALBIN)/gci
KUSTOMIZE_VERSION ?= v5.4.3
CONTROLLER_TOOLS_VERSION ?= v0.16.1
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.62.2
GOLANGCI_LINT_VERSION ?= v2.3.0
HELM_VERSION ?= v3.17.1
KUBECTL_VALIDATE_VERSION ?= v0.0.4
GCI_VERSION ?= v0.13.6
Expand All @@ -396,7 +396,7 @@ $(ENVTEST): $(LOCALBIN)
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: yq
yq: ## Download yq locally if necessary.
Expand Down
2 changes: 1 addition & 1 deletion conformance/conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func ensureGatewayAvailableAndReady(t *testing.T, k8sClient client.Client, opts
extTimeoutConf := inferenceconfig.DefaultInferenceExtensionTimeoutConfig()

// Use the GatewayMustHaveAddress timeout from the suite's base TimeoutConfig for the Gateway object to appear.
waitForGatewayCreationTimeout := extTimeoutConf.TimeoutConfig.GatewayMustHaveAddress
waitForGatewayCreationTimeout := extTimeoutConf.GatewayMustHaveAddress

logDebugf(t, opts.Debug, "Waiting up to %v for Gateway object %s/%s to appear after manifest application...", waitForGatewayCreationTimeout, gatewayNN.Namespace, gatewayNN.Name)

Expand Down
5 changes: 2 additions & 3 deletions conformance/tests/basic/gateway_following_epp_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
trafficutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
)

func init() {
Expand Down Expand Up @@ -94,12 +93,12 @@ var GatewayFollowingEPPRouting = suite.ConformanceTest{
for i := 0; i < len(pods); i++ {
// Send an initial request targeting a single pod and wait for it to be successful to ensure the Gateway and EPP
// are functioning correctly before running the main test cases.
trafficutils.MakeRequestAndExpectSuccess(
traffic.MakeRequestAndExpectSuccess(
t,
s.RoundTripper,
s.TimeoutConfig,
gwAddr,
trafficutils.Request{
traffic.Request{
Host: hostname,
Path: path,
Headers: map[string]string{eppSelectionHeaderName: podIPs[i]},
Expand Down
6 changes: 3 additions & 3 deletions conformance/utils/kubernetes/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func checkCondition(t *testing.T, conditions []metav1.Condition, expectedConditi
func InferencePoolMustHaveCondition(t *testing.T, c client.Reader, poolNN types.NamespacedName, expectedCondition metav1.Condition) {
t.Helper() // Marks this function as a test helper

var timeoutConfig config.InferenceExtensionTimeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
var timeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
var lastObservedPool *inferenceapi.InferencePool
var lastError error
var conditionFound bool
Expand Down Expand Up @@ -165,7 +165,7 @@ func InferencePoolMustHaveNoParents(t *testing.T, c client.Reader, poolNN types.

var lastObservedPool *inferenceapi.InferencePool
var lastError error
var timeoutConfig config.InferenceExtensionTimeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
var timeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()

ctx := context.Background()
waitErr := wait.PollUntilContextTimeout(
Expand Down Expand Up @@ -286,7 +286,7 @@ func HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(
gatewayNN types.NamespacedName,
poolNN types.NamespacedName) {
t.Helper()
var timeoutConfig config.InferenceExtensionTimeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()
var timeoutConfig = config.DefaultInferenceExtensionTimeoutConfig()

HTTPRouteMustBeAcceptedAndResolved(t, c, timeoutConfig.TimeoutConfig, routeNN, gatewayNN)
InferencePoolMustBeRouteAccepted(t, c, poolNN)
Expand Down
15 changes: 7 additions & 8 deletions pkg/bbr/handlers/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

basepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
eppb "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
extProcPb "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
"sigs.k8s.io/controller-runtime/pkg/log"

"sigs.k8s.io/gateway-api-inference-extension/pkg/bbr/metrics"
Expand Down Expand Up @@ -122,13 +121,13 @@ func (s *Server) HandleRequestBody(ctx context.Context, requestBodyBytes []byte)
}

func addStreamedBodyResponse(responses []*eppb.ProcessingResponse, requestBodyBytes []byte) []*eppb.ProcessingResponse {
return append(responses, &extProcPb.ProcessingResponse{
Response: &extProcPb.ProcessingResponse_RequestBody{
RequestBody: &extProcPb.BodyResponse{
Response: &extProcPb.CommonResponse{
BodyMutation: &extProcPb.BodyMutation{
Mutation: &extProcPb.BodyMutation_StreamedResponse{
StreamedResponse: &extProcPb.StreamedBodyResponse{
return append(responses, &eppb.ProcessingResponse{
Response: &eppb.ProcessingResponse_RequestBody{
RequestBody: &eppb.BodyResponse{
Response: &eppb.CommonResponse{
BodyMutation: &eppb.BodyMutation{
Mutation: &eppb.BodyMutation_StreamedResponse{
StreamedResponse: &eppb.StreamedBodyResponse{
Body: requestBodyBytes,
EndOfStream: true,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/epp/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (ds *datastore) ModelSetIfOlder(infModel *v1alpha2.InferenceModel) bool {
existing, exists := ds.models[infModel.Spec.ModelName]
if exists {
diffObj := infModel.Name != existing.Name || infModel.Namespace != existing.Namespace
if diffObj && existing.ObjectMeta.CreationTimestamp.Before(&infModel.ObjectMeta.CreationTimestamp) {
if diffObj && existing.CreationTimestamp.Before(&infModel.CreationTimestamp) {
return false
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func (ds *datastore) ModelResync(ctx context.Context, reader client.Reader, mode
!m.DeletionTimestamp.IsZero() { // ignore objects marked for deletion
continue
}
if oldest == nil || m.ObjectMeta.CreationTimestamp.Before(&oldest.ObjectMeta.CreationTimestamp) {
if oldest == nil || m.CreationTimestamp.Before(&oldest.CreationTimestamp) {
oldest = m
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/epp/util/testing/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (p *PodWrapper) IP(ip string) *PodWrapper {
func (p *PodWrapper) DeletionTimestamp() *PodWrapper {
now := metav1.Now()
p.ObjectMeta.DeletionTimestamp = &now
p.ObjectMeta.Finalizers = []string{"finalizer"}
p.Finalizers = []string{"finalizer"}
return p
}

Expand Down Expand Up @@ -160,7 +160,7 @@ func (m *InferenceModelWrapper) Criticality(criticality v1alpha2.Criticality) *I
func (m *InferenceModelWrapper) DeletionTimestamp() *InferenceModelWrapper {
now := metav1.Now()
m.ObjectMeta.DeletionTimestamp = &now
m.ObjectMeta.Finalizers = []string{"finalizer"}
m.Finalizers = []string{"finalizer"}
return m
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func main() {
crdRaw := parser.CustomResourceDefinitions[groupKind]

// Inline version of "addAttribution(&crdRaw)" ...
if crdRaw.ObjectMeta.Annotations == nil {
crdRaw.ObjectMeta.Annotations = map[string]string{}
if crdRaw.Annotations == nil {
crdRaw.Annotations = map[string]string{}
}
crdRaw.ObjectMeta.Annotations[version.BundleVersionAnnotation] = version.BundleVersion
crdRaw.Annotations[version.BundleVersionAnnotation] = version.BundleVersion

// Prevent the top level metadata for the CRD to be generated regardless of the intention in the arguments
crd.FixTopLevelMetadata(crdRaw)
Expand Down