Skip to content

Commit

Permalink
Update k8s libraries to v1.31.1 (antrea-io#6681)
Browse files Browse the repository at this point in the history
- Update K8s libraries to v1.31.1
- Update sigs.k8s.io/controller-runtime to v0.19.0
- Update controller-gen to v0.16.3
- Use ubuntu:24.04 as base image for codegen

Some of the key changes that were caused by these updates:
- Most functions in `k8s.io/client-go/util/workqueue` have been
  deprecated and were replaced with typed functions (using Go generics)
- The `Version` field no longer exists in the generic apiserver
  config. It has been replaced with `EffectiveVersion` (this is because
  kube-apiserver now supports version emulation for more robust K8s
  version upgrades). `EffectiveVersion` is not required (`Version` used
  to be optional), and I am not sure whether that was an intentional
  change. `EffectiveVersion` is used (instead of `Version`) to configure
  the `/version` route. At the moment we have no intention of supporting
  version emulation in the Antrea Controller, but we could in the
  future. As far as I can tell, other changes relating to version
  emulation support do not affect Antrea.
- The arguments to code generators have changed quite a bit.
- The code generated for client-go (by `client-gen`) is now more generic
  (it leverages Go generics), so as a result the generated code is less
  verbose.
- controller-gen now requires uniqueness for controller names (across
  all controllers in the program), for metrics reporting
  purposes. Because of this, we had to assign unique names manually to
  all controllers (and the name validation needs to be explicitly
  skipped in unit tests).
  • Loading branch information
antoninbas authored and hangyan committed Oct 29, 2024
1 parent 27c931a commit 8238779
Show file tree
Hide file tree
Showing 246 changed files with 4,032 additions and 6,517 deletions.
8 changes: 3 additions & 5 deletions build/images/codegen/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

ARG GO_VERSION
FROM ubuntu:22.04 AS protoc
FROM ubuntu:24.04 AS protoc

RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates unzip
Expand All @@ -30,13 +30,11 @@ FROM golang:${GO_VERSION}
LABEL maintainer="Antrea <projectantrea-dev@googlegroups.com>"
LABEL description="A Docker image based on the golang image, which includes codegen tools."

ENV GO111MODULE=on

ARG K8S_VERSION=1.29.2
ARG K8S_VERSION=1.31.1
# The k8s.io/kube-openapi repo does not have tag, using a workable commit hash.
# We use the version that is referenced in the Kubernetes go.mod (for the
# correct K8s version).
ARG KUBEOPENAPI_VERSION=v0.0.0-20231010175941-2dd684a91f00
ARG KUBEOPENAPI_VERSION=v0.0.0-20240228011516-70dd3763d340

RUN go install k8s.io/code-generator/cmd/client-gen@kubernetes-$K8S_VERSION && \
go install k8s.io/code-generator/cmd/deepcopy-gen@kubernetes-$K8S_VERSION && \
Expand Down
3 changes: 2 additions & 1 deletion build/images/codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ can run the following:
```bash
cd build/images/codegen
GO_VERSION=$(head -n 1 ../deps/go-version)
docker build -t antrea/codegen:<TAG> --build-arg GO_VERSION=$GO_VERSION .
docker build --pull -t antrea/codegen:<TAG> --build-arg GO_VERSION=$GO_VERSION .
docker push antrea/codegen:<TAG>
```

Expand All @@ -22,6 +22,7 @@ Here is the table of codegen images that have been uploaded:

| Tag | Change |
| :------------------------ | ----------------------------------------------------------------------------- |
| kubernetes-1.31.1 | Upgraded K8s libraries to v1.31.1, controller-gen to v0.16.3, ubuntu to 24.04 |
| kubernetes-1.29.2-build.3 | Upgraded Go to v1.23 |
| kubernetes-1.29.2-build.2 | Upgraded go.uber.org/mock/mockgen to v0.4.0 |
| kubernetes-1.29.2-build.1 | Upgraded controller-gen to v0.14.0 |
Expand Down
2 changes: 1 addition & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ func run(o *Options) error {
return fmt.Errorf("error when getting generated cert for agent API server")
}

go apiServer.Run(stopCh)
go apiServer.Run(ctx)

// The API certificate is passed on directly to the monitor, instead of being provided by
// the agentQuerier. This is to avoid a circular dependency between apiServer and
Expand Down
8 changes: 4 additions & 4 deletions cmd/antrea-agent/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestOptionsValidateAntreaProxyConfig(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.LoadBalancerModeDSR, tt.enabledDSR)()
featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.LoadBalancerModeDSR, tt.enabledDSR)

o := &Options{config: &agentconfig.AgentConfig{
AntreaProxy: tt.antreaProxyConfig,
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestOptionsValidateEgressConfig(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.Egress, tt.featureGateValue)()
featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.Egress, tt.featureGateValue)

o := &Options{config: &agentconfig.AgentConfig{
Egress: tt.egressConfig,
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestOptionsValidateMulticastConfig(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.Multicast, true)()
featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.Multicast, true)
o := &Options{config: &agentconfig.AgentConfig{
Multicast: agentconfig.MulticastConfig{
Enable: true,
Expand Down Expand Up @@ -325,7 +325,7 @@ func TestOptionsValidateSecondaryNetworkConfig(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.SecondaryNetwork, tc.featureGateValue)()
featuregatetesting.SetFeatureGateDuringTest(t, features.DefaultFeatureGate, features.SecondaryNetwork, tc.featureGateValue)

o := &Options{config: &agentconfig.AgentConfig{}}
for _, brName := range tc.ovsBridges {
Expand Down
2 changes: 2 additions & 0 deletions cmd/antrea-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
genericopenapi "k8s.io/apiserver/pkg/endpoints/openapi"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
apiserverversion "k8s.io/apiserver/pkg/util/version"
"k8s.io/client-go/informers"
csrinformers "k8s.io/client-go/informers/certificates/v1"
coreinformers "k8s.io/client-go/informers/core/v1"
Expand Down Expand Up @@ -547,6 +548,7 @@ func createAPIServerConfig(kubeconfig string,
openapi.GetOpenAPIDefinitions,
genericopenapi.NewDefinitionNamer(apiserver.Scheme))
serverConfig.OpenAPIConfig.Info.Title = "Antrea"
serverConfig.EffectiveVersion = apiserverversion.NewEffectiveVersion(version.GetFullVersion())
serverConfig.EnableMetrics = enableMetrics
serverConfig.MinRequestTimeout = int(serverMinWatchTimeout.Seconds())
serverConfig.SecureServing.CipherSuites = cipherSuites
Expand Down
8 changes: 7 additions & 1 deletion cmd/flow-aggregator/flow-aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"context"
"fmt"
"sync"
"time"
Expand All @@ -41,6 +42,11 @@ func run(configFile string) error {
// cause the stopCh channel to be closed; if another signal is received before the program
// exits, we will force exit.
stopCh := signals.RegisterSignalHandlers()
// Generate a context for functions which require one (instead of stopCh).
// We cancel the context when the function returns, which in the normal case will be when
// stopCh is closed.
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

log.StartLogFileNumberMonitor(stopCh)

Expand Down Expand Up @@ -81,7 +87,7 @@ func run(configFile string) error {
if err != nil {
return fmt.Errorf("error when creating flow aggregator API server: %v", err)
}
go apiServer.Run(stopCh)
go apiServer.Run(ctx)

informerFactory.Start(stopCh)

Expand Down
96 changes: 49 additions & 47 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/containernetworking/cni v1.2.0
github.com/containernetworking/plugins v1.1.1
github.com/coreos/go-iptables v0.8.0
github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/fatih/color v1.17.0
github.com/fsnotify/fsnotify v1.7.0
github.com/gammazero/deque v0.1.2
Expand All @@ -43,8 +43,8 @@ require (
github.com/onsi/gomega v1.34.1
github.com/osrg/gobgp/v3 v3.29.0
github.com/pkg/sftp v1.13.6
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/common v0.47.0
github.com/prometheus/client_golang v1.19.1
github.com/prometheus/common v0.55.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.1
Expand All @@ -67,22 +67,22 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.29.2
k8s.io/apiextensions-apiserver v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/apiserver v0.29.2
k8s.io/client-go v0.29.2
k8s.io/component-base v0.29.2
k8s.io/klog/v2 v2.110.1
k8s.io/kube-aggregator v0.29.2
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00
k8s.io/kubectl v0.29.2
k8s.io/kubelet v0.29.2
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/controller-runtime v0.16.3
k8s.io/api v0.31.1
k8s.io/apiextensions-apiserver v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/apiserver v0.31.1
k8s.io/client-go v0.31.1
k8s.io/component-base v0.31.1
k8s.io/klog/v2 v2.130.1
k8s.io/kube-aggregator v0.31.1
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340
k8s.io/kubectl v0.31.1
k8s.io/kubelet v0.31.1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/mcs-api v0.1.0
sigs.k8s.io/network-policy-api v0.1.1
sigs.k8s.io/yaml v1.3.0
sigs.k8s.io/yaml v1.4.0
)

require (
Expand All @@ -94,7 +94,7 @@ require (
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/alexflint/go-filemutex v1.2.0 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/armon/go-metrics v0.4.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.4 // indirect
Expand All @@ -114,7 +114,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenk/hub v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/hub v1.0.1 // indirect
github.com/cenkalti/rpc2 v0.0.0-20180727162946-9642ea02d0aa // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand All @@ -129,21 +129,21 @@ require (
github.com/eapache/queue v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.6.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.17.7 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand All @@ -152,7 +152,7 @@ require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.1 // indirect
Expand Down Expand Up @@ -180,8 +180,8 @@ require (
github.com/mdlayher/socket v0.5.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/moby/spdystream v0.4.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
Expand All @@ -196,9 +196,9 @@ require (
github.com/pion/transport/v2 v2.0.0 // indirect
github.com/pion/udp v0.1.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1 // indirect
Expand All @@ -212,24 +212,25 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/ti-mo/netfilter v0.5.2 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/v3 v3.5.10 // indirect
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect
go.etcd.io/etcd/client/v3 v3.5.14 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0 // indirect
go.opentelemetry.io/otel v1.20.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.20.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.20.0 // indirect
go.opentelemetry.io/otel/metric v1.20.0 // indirect
go.opentelemetry.io/otel/sdk v1.20.0 // indirect
go.opentelemetry.io/otel/trace v1.20.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/term v0.24.0 // indirect
Expand All @@ -239,13 +240,14 @@ require (
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
k8s.io/cli-runtime v0.29.2 // indirect
k8s.io/kms v0.29.2 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect
k8s.io/cli-runtime v0.31.1 // indirect
k8s.io/kms v0.31.1 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/api v0.17.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
Loading

0 comments on commit 8238779

Please sign in to comment.