Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
44 changes: 20 additions & 24 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
version: "2"

run:
timeout: 5m
go: "1.25.0"
modules-download-mode: vendor

linters:
default: none
enable:
Expand All @@ -7,31 +13,21 @@ linters:
- revive
- unused
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- path: _test\.go
linters:
- gosec
path: _test\.go
- linters:
- path: ^tests/
linters:
- gosec
path: ^tests/
paths:
- third_party$
- builtin$
- examples$
issues:
fix: true
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
- third_party/
- builtin/
- examples/
settings:
revive:
rules:
- name: exported
disabled: true
- name: package-comments
disabled: true
32 changes: 17 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ALL_ARCH ?= amd64 arm arm64 ppc64le s390x
# The output type could either be docker (local), or registry.
OUTPUT_TYPE ?= docker
GO_TOOLCHAIN ?= golang
GO_VERSION ?= 1.26.2
GO_VERSION := 1.25.0
GOTOOLCHAIN ?= go$(GO_VERSION)+auto
export GOTOOLCHAIN
BASEIMAGE ?= gcr.io/distroless/static-debian12:nonroot
Expand Down Expand Up @@ -78,30 +78,30 @@ mock_gen:
# Unit tests with faster execution (nicer for development).
.PHONY: fast-test
fast-test:
go test -mod=vendor -race $(shell go list ./... | grep -v -e "/e2e$$" -e "/e2e/.*")
cd konnectivity-client && go test -race ./...
GOTOOLCHAIN=go$(GO_VERSION) go test -mod=vendor -race $(shell go list ./... | grep -v -e "/e2e$$" -e "/e2e/.*")
cd konnectivity-client && GOTOOLCHAIN=go$(GO_VERSION) go test -race ./...

# Unit tests with fuller coverage, invoked by CI system.
.PHONY: test
test:
$(eval TEST_LIST := $(shell go list -test ./... | egrep " \[.*\]" | cut -d' ' -f1 | grep -v -e "/e2e$$" -e "/e2e/.*"))
$(eval TEST_LIST := $(shell GOTOOLCHAIN=go$(GO_VERSION) go list -test ./... | egrep " \[.*\]" | cut -d' ' -f1 | grep -v -e "/e2e$$" -e "/e2e/.*"))
echo "Running tests on $(TEST_LIST)"
$(info GOTOOLCHAIN is $(GOTOOLCHAIN))
go test -v -mod=vendor -race -covermode=atomic -coverprofile=konnectivity.out $(TEST_LIST) && go tool cover -html=konnectivity.out -o=konnectivity.html
cd konnectivity-client && go test -race -covermode=atomic -coverprofile=client.out ./... && go tool cover -html=client.out -o=client.html
GOTOOLCHAIN=go$(GO_VERSION) go test -v -mod=vendor -race -covermode=atomic -coverprofile=konnectivity.out $(TEST_LIST) && GOTOOLCHAIN=go$(GO_VERSION) go tool cover -html=konnectivity.out -o=konnectivity.html
cd konnectivity-client && GOTOOLCHAIN=go$(GO_VERSION) go test -race -covermode=atomic -coverprofile=client.out ./... && GOTOOLCHAIN=go$(GO_VERSION) go tool cover -html=client.out -o=client.html

.PHONY: test-integration
test-integration: build
go test -mod=vendor -race ./tests -agent-path $(PWD)/bin/proxy-agent
GOTOOLCHAIN=go$(GO_VERSION) go test -mod=vendor -race ./tests -agent-path $(PWD)/bin/proxy-agent

.PHONY: test-e2e
test-e2e: docker-build
go test -mod=vendor ./e2e -race -agent-image ${AGENT_FULL_IMAGE}-$(TARGETARCH):${TAG} -server-image ${SERVER_FULL_IMAGE}-$(TARGETARCH):${TAG} -kind-image ${KIND_IMAGE} -mode ${CONNECTION_MODE}
GOTOOLCHAIN=go$(GO_VERSION) go test -mod=vendor ./e2e -race -agent-image ${AGENT_FULL_IMAGE}-$(TARGETARCH):${TAG} -server-image ${SERVER_FULL_IMAGE}-$(TARGETARCH):${TAG} -kind-image ${KIND_IMAGE} -mode ${CONNECTION_MODE}

# e2e test runner for continuous integration that does not build a new image.
.PHONY: test-e2e-ci
test-e2e-ci:
go test -mod=vendor ./e2e -race -agent-image ${AGENT_FULL_IMAGE}-$(TARGETARCH):${TAG} -server-image ${SERVER_FULL_IMAGE}-$(TARGETARCH):${TAG} -kind-image ${KIND_IMAGE} -mode ${CONNECTION_MODE}
GOTOOLCHAIN=go$(GO_VERSION) go test -mod=vendor ./e2e -race -agent-image ${AGENT_FULL_IMAGE}-$(TARGETARCH):${TAG} -server-image ${SERVER_FULL_IMAGE}-$(TARGETARCH):${TAG} -kind-image ${KIND_IMAGE} -mode ${CONNECTION_MODE}

## --------------------------------------
## Binaries
Expand All @@ -115,28 +115,30 @@ build: bin/proxy-agent bin/proxy-server bin/proxy-test-client bin/http-test-serv

.PHONY: bin/proxy-agent
bin/proxy-agent:
GO111MODULE=on go build -mod=vendor -o bin/proxy-agent cmd/agent/main.go
GOTOOLCHAIN=go$(GO_VERSION) GO111MODULE=on go build -mod=vendor -o bin/proxy-agent cmd/agent/main.go

.PHONY: bin/proxy-test-client
bin/proxy-test-client:
GO111MODULE=on go build -mod=vendor -o bin/proxy-test-client cmd/test-client/main.go
GOTOOLCHAIN=go$(GO_VERSION) GO111MODULE=on go build -mod=vendor -o bin/proxy-test-client cmd/test-client/main.go

.PHONY: bin/http-test-server
bin/http-test-server:
GO111MODULE=on go build -mod=vendor -o bin/http-test-server cmd/test-server/main.go
GOTOOLCHAIN=go$(GO_VERSION) GO111MODULE=on go build -mod=vendor -o bin/http-test-server cmd/test-server/main.go

.PHONY: bin/proxy-server
bin/proxy-server:
GO111MODULE=on go build -mod=vendor -o bin/proxy-server cmd/server/main.go
GOTOOLCHAIN=go$(GO_VERSION) GO111MODULE=on go build -mod=vendor -o bin/proxy-server cmd/server/main.go

## --------------------------------------
## Linting
## --------------------------------------

.PHONY: lint
lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_LOCATION) v$(GOLANGCI_LINT_VERSION)
$(INSTALL_LOCATION)/golangci-lint run --config ./.golangci.yaml --verbose
if [ ! -f $(INSTALL_LOCATION)/golangci-lint ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_LOCATION) v$(GOLANGCI_LINT_VERSION); \
fi
GOTOOLCHAIN=go$(GO_VERSION) $(INSTALL_LOCATION)/golangci-lint run --config ./.golangci.yaml --verbose --timeout 5m

## --------------------------------------
## Go
Expand Down
4 changes: 3 additions & 1 deletion artifacts/images/agent-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

ARG BUILDARCH
ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG GO_VERSION=1.25.0
ARG BASEIMAGE

FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder

ENV GOTOOLCHAIN=local

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

Expand Down
4 changes: 3 additions & 1 deletion artifacts/images/server-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

ARG BUILDARCH
ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG GO_VERSION=1.25.0
ARG BASEIMAGE

FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder

ENV GOTOOLCHAIN=local

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

Expand Down
4 changes: 3 additions & 1 deletion artifacts/images/test-client-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

ARG BUILDARCH
ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG GO_VERSION=1.25.0
ARG BASEIMAGE

FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder

ENV GOTOOLCHAIN=local

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

Expand Down
4 changes: 3 additions & 1 deletion artifacts/images/test-server-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

ARG BUILDARCH
ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG GO_VERSION=1.25.0
ARG BASEIMAGE

FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder

ENV GOTOOLCHAIN=local

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy

Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ func (a *Agent) Run(o *options.GrpcProxyAgentOptions, drainCh, stopCh <-chan str
if err := a.runHealthServer(o, cs); err != nil {
return fmt.Errorf("failed to run health server with %v", err)
}
defer a.healthServer.Close()
defer func() { _ = a.healthServer.Close() }()

if err := a.runAdminServer(o); err != nil {
return fmt.Errorf("failed to run admin server with %v", err)
}
defer a.adminServer.Close()
defer func() { _ = a.adminServer.Close() }()

<-stopCh
klog.V(1).Infoln("Shutting down agent.")
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (o *ProxyRunOptions) Flags() *pflag.FlagSet {
flags.StringVar(&o.LeaseLabel, "lease-label", o.LeaseLabel, "The labels on which the lease objects are managed.")
flags.DurationVar(&o.GracefulShutdownTimeout, "graceful-shutdown-timeout", o.GracefulShutdownTimeout, "Timeout duration for graceful shutdown of the server. The server will wait for active connections to close before forcefully terminating. Set to 0 to disable graceful shutdown (default: 0).")
flags.Bool("warn-on-channel-limit", true, "This behavior is now thread safe and always on. This flag will be removed in a future release.")
flags.MarkDeprecated("warn-on-channel-limit", "This behavior is now thread safe and always on. This flag will be removed in a future release.")
_ = flags.MarkDeprecated("warn-on-channel-limit", "This behavior is now thread safe and always on. This flag will be removed in a future release.")

return flags
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/server/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ func (p *Proxy) Run(o *options.ProxyRunOptions, stopCh <-chan struct{}) error {
p.agentServer.Stop()
}
if p.adminServer != nil {
p.adminServer.Close()
_ = p.adminServer.Close()
}
if p.healthServer != nil {
p.healthServer.Close()
_ = p.healthServer.Close()
}
if leaseController != nil {
leaseController.Stop()
Expand Down Expand Up @@ -286,10 +286,10 @@ func (p *Proxy) Run(o *options.ProxyRunOptions, stopCh <-chan struct{}) error {
p.agentServer.Stop()
}
if p.adminServer != nil {
p.adminServer.Close()
_ = p.adminServer.Close()
}
if p.healthServer != nil {
p.healthServer.Close()
_ = p.healthServer.Close()
}
// frontend server's force-stop is handled by its StopFunc
}
Expand Down Expand Up @@ -365,7 +365,7 @@ func (p *Proxy) runUDSFrontendServer(ctx context.Context, o *options.ProxyRunOpt
"core", "udsGrpcFrontend",
"udsFile", o.UdsName,
)
go runpprof.Do(context.Background(), labels, func(context.Context) { grpcServer.Serve(lis) })
go runpprof.Do(context.Background(), labels, func(context.Context) { _ = grpcServer.Serve(lis) })
stop = func(_ context.Context) error {
grpcServer.GracefulStop()
return nil
Expand Down Expand Up @@ -463,7 +463,7 @@ func (p *Proxy) runMTLSFrontendServer(_ context.Context, o *options.ProxyRunOpti
"core", "mtlsGrpcFrontend",
"port", strconv.Itoa(o.ServerPort),
)
go runpprof.Do(context.Background(), labels, func(context.Context) { grpcServer.Serve(lis) })
go runpprof.Do(context.Background(), labels, func(context.Context) { _ = grpcServer.Serve(lis) })
stop = func(_ context.Context) error {
grpcServer.GracefulStop()
return nil
Expand Down Expand Up @@ -523,7 +523,7 @@ func (p *Proxy) runAgentServer(o *options.ProxyRunOptions, server *server.ProxyS
"core", "agentListener",
"port", strconv.Itoa(o.AgentPort),
)
go runpprof.Do(context.Background(), labels, func(context.Context) { grpcServer.Serve(lis) })
go runpprof.Do(context.Background(), labels, func(context.Context) { _ = grpcServer.Serve(lis) })
p.agentServer = grpcServer

return nil
Expand Down
43 changes: 25 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/apiserver-network-proxy

go 1.26.2
go 1.25.0

require (
github.com/google/uuid v1.6.0
Expand All @@ -15,14 +15,14 @@ require (
golang.org/x/net v0.53.0
google.golang.org/grpc v1.80.0
google.golang.org/protobuf v1.36.11
k8s.io/api v0.34.0
k8s.io/apimachinery v0.34.0
k8s.io/client-go v0.34.0
k8s.io/component-base v0.34.0
k8s.io/component-helpers v0.34.0
k8s.io/api v0.35.0
k8s.io/apimachinery v0.35.0
k8s.io/client-go v0.35.0
k8s.io/component-base v0.35.0
k8s.io/component-helpers v0.35.0
k8s.io/klog/v2 v2.140.0
k8s.io/utils v0.0.0-20260507154919-ff6756f316d2
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2
sigs.k8s.io/controller-runtime v0.20.3
sigs.k8s.io/e2e-framework v0.6.0
)
Expand All @@ -32,31 +32,37 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/go-openapi/swag v0.25.4 // indirect
github.com/go-openapi/swag/cmdutils v0.25.4 // indirect
github.com/go-openapi/swag/conv v0.25.4 // indirect
github.com/go-openapi/swag/fileutils v0.25.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
github.com/go-openapi/swag/loading v0.25.4 // indirect
github.com/go-openapi/swag/mangling v0.25.4 // indirect
github.com/go-openapi/swag/netutils v0.25.4 // indirect
github.com/go-openapi/swag/stringutils v0.25.4 // indirect
github.com/go-openapi/swag/typeutils v0.25.4 // indirect
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/moby/spdystream v0.5.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/vladimirvivien/gexe v0.4.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/otel v1.41.0 // indirect
Expand All @@ -69,13 +75,14 @@ require (
golang.org/x/text v0.36.0 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
k8s.io/apiextensions-apiserver v0.35.0 // indirect
k8s.io/kube-openapi v0.0.0-20260507235316-19c3011e7fa0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)

Expand Down
Loading