Skip to content

Commit

Permalink
Merge pull request #684 from cheftako/master
Browse files Browse the repository at this point in the history
Updated golang version to 1.23.0
  • Loading branch information
k8s-ci-robot authored Jan 17, 2025
2 parents c1a1e09 + c9a0e65 commit a515c83
Show file tree
Hide file tree
Showing 24 changed files with 1,556 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ permissions:
contents: read

env:
GO_VERSION: v1.22
GOLANGCI_LINT_VERSION: v1.56
GO_VERSION: v1.23
GOLANGCI_LINT_VERSION: v1.60.1

jobs:
golangci:
Expand Down
6 changes: 3 additions & 3 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.22.7
GO_VERSION ?= 1.23.0
BASEIMAGE ?= gcr.io/distroless/static-debian11:nonroot

ifeq ($(GOPATH),)
Expand All @@ -33,7 +33,7 @@ endif
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
INSTALL_LOCATION:=$(shell go env GOPATH)/bin
GOLANGCI_LINT_VERSION ?= 1.56.2
GOLANGCI_LINT_VERSION ?= 1.60.1
GOSEC_VERSION ?= 2.13.1

REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
Expand Down Expand Up @@ -125,7 +125,7 @@ bin/proxy-server:
.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 --verbose
$(INSTALL_LOCATION)/golangci-lint run --config ./.golangci.yaml --verbose

## --------------------------------------
## Go
Expand Down
2 changes: 1 addition & 1 deletion artifacts/images/agent-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG BASEIMAGE

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

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy
Expand Down
2 changes: 1 addition & 1 deletion artifacts/images/server-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG BASEIMAGE

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

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy
Expand Down
2 changes: 1 addition & 1 deletion artifacts/images/test-client-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG BASEIMAGE

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

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy
Expand Down
2 changes: 1 addition & 1 deletion artifacts/images/test-server-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG GO_TOOLCHAIN
ARG GO_VERSION
ARG BASEIMAGE

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

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (p *Proxy) runHealthServer(o *options.ProxyRunOptions, server *server.Proxy
return
}
w.WriteHeader(500)
fmt.Fprintf(w, msg)
fmt.Fprint(w, msg)
})

muxHandler := http.NewServeMux()
Expand Down
3 changes: 2 additions & 1 deletion 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.22.7
go 1.23.0

require (
github.com/google/uuid v1.6.0
Expand Down Expand Up @@ -40,6 +40,7 @@ require (
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
Expand Down Expand Up @@ -122,6 +124,7 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
Expand All @@ -137,22 +140,29 @@ golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6R
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -165,6 +175,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 0 additions & 1 deletion konnectivity-client/proto/client/client.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/agent/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (

const (
fromResponses = "KNP server response headers"
fromLeases = "KNP lease count"
fromFallback = "fallback to 1"
fromLeases = "KNP lease count"
fromFallback = "fallback to 1"
)

// ClientSet consists of clients connected to each instance of an HA proxy server.
Expand All @@ -46,8 +46,8 @@ type ClientSet struct {
address string // proxy server address. Assuming HA proxy server

leaseCounter ServerCounter // counts number of proxy server leases
lastReceivedServerCount int // last server count received from a proxy server
lastServerCount int // last server count value from either lease system or proxy server, former takes priority
lastReceivedServerCount int // last server count received from a proxy server
lastServerCount int // last server count value from either lease system or proxy server, former takes priority

// unless it is an HA server. Initialized when the ClientSet creates
// the first client. When syncForever is set, it will be the most recently seen.
Expand All @@ -73,7 +73,7 @@ type ClientSet struct {
warnOnChannelLimit bool
xfrChannelSize int

syncForever bool // Continue syncing (support dynamic server count).
syncForever bool // Continue syncing (support dynamic server count).
serverCountSource string
}

Expand Down
57 changes: 28 additions & 29 deletions pkg/agent/clientset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,59 +29,58 @@ func (f *FakeServerCounter) Count() int {
}

func TestServerCount(t *testing.T) {
testCases := []struct{
name string
testCases := []struct {
name string
serverCountSource string
leaseCounter ServerCounter
responseCount int
want int
} {
leaseCounter ServerCounter
responseCount int
want int
}{
{
name: "higher from response",
name: "higher from response",
serverCountSource: "max",
responseCount: 42,
leaseCounter: &FakeServerCounter{24},
want: 42,
responseCount: 42,
leaseCounter: &FakeServerCounter{24},
want: 42,
},
{
name: "higher from leases",
name: "higher from leases",
serverCountSource: "max",
responseCount: 3,
leaseCounter: &FakeServerCounter{6},
want: 6,
responseCount: 3,
leaseCounter: &FakeServerCounter{6},
want: 6,
},
{
name: "both zero",
name: "both zero",
serverCountSource: "max",
responseCount: 0,
leaseCounter: &FakeServerCounter{0},
want: 1,
responseCount: 0,
leaseCounter: &FakeServerCounter{0},
want: 1,
},

{
name: "response picked by default when no lease counter",
name: "response picked by default when no lease counter",
serverCountSource: "default",
responseCount: 3,
leaseCounter: nil,
want: 3,
responseCount: 3,
leaseCounter: nil,
want: 3,
},
{
name: "lease counter always picked when present",
name: "lease counter always picked when present",
serverCountSource: "default",
responseCount: 6,
leaseCounter: &FakeServerCounter{3},
want: 3,
responseCount: 6,
leaseCounter: &FakeServerCounter{3},
want: 3,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {

cs := &ClientSet{
clients: make(map[string]*Client),
leaseCounter: tc.leaseCounter,
clients: make(map[string]*Client),
leaseCounter: tc.leaseCounter,
serverCountSource: tc.serverCountSource,

}
cs.lastReceivedServerCount = tc.responseCount
if got := cs.ServerCount(); got != tc.want {
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/backend_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"reflect"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
"google.golang.org/grpc/metadata"

agentmock "sigs.k8s.io/apiserver-network-proxy/proto/agent/mocks"
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/google/uuid"
"go.uber.org/mock/gomock"
"google.golang.org/grpc/metadata"

promtest "github.com/prometheus/client_golang/prometheus/testutil"
Expand Down
23 changes: 9 additions & 14 deletions proto/agent/mocks/agent_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a515c83

Please sign in to comment.