Skip to content

Commit 6a65a9e

Browse files
authored
Upgrade controller runtime to v0.17.5 and k8s api to v0.29.5 (#4160)
* upgrade controller runtime version to 0.17.5 Signed-off-by: xliuqq <[email protected]> * fix go mod Signed-off-by: xliuqq <[email protected]> * fix pointer to ptr Signed-off-by: xliuqq <[email protected]> * update from master Signed-off-by: xliuqq <[email protected]> * fix api change Signed-off-by: xliuqq <[email protected]> * fix go mod conflict Signed-off-by: xliuqq <[email protected]> * empty line to trigger new test Signed-off-by: xliuqq <[email protected]> * fix comment Signed-off-by: xliuqq <[email protected]> * order import and add todo for offset Signed-off-by: xliuqq <[email protected]> --------- Signed-off-by: xliuqq <[email protected]>
1 parent 81fafee commit 6a65a9e

File tree

1,067 files changed

+125505
-77732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,067 files changed

+125505
-77732
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ docker-buildx-all-push: pre-setup ${DOCKER_BUILDX_PUSH}
331331

332332
# find or download controller-gen
333333
# download controller-gen if necessary
334-
# controller-gen@v0.12.1 comply with k8s.io/api v0.26.x
334+
# controller-gen@v0.14.0 comply with k8s.io/api v0.29.x
335335
controller-gen:
336336
ifeq (, $(shell which controller-gen))
337337
@{ \
@@ -340,7 +340,7 @@ ifeq (, $(shell which controller-gen))
340340
cd $$CONTROLLER_GEN_TMP_DIR ;\
341341
export GO111MODULE=on ;\
342342
go mod init tmp ;\
343-
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.1 ;\
343+
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 ;\
344344
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
345345
}
346346
CONTROLLER_GEN=$(GOBIN)/controller-gen

api/v1alpha1/openapi_generated.go

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.deepcopy.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/fluid/fluid/crds/data.fluid.io_alluxioruntimes.yaml

+2,119-1,912
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_databackups.yaml

+83-86
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_dataloads.yaml

+566-504
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_datamigrates.yaml

+569-507
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_dataprocesses.yaml

+4,435-4,667
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_datasets.yaml

+99-91
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_efcruntimes.yaml

+1,068-1,033
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_goosefsruntimes.yaml

+1,242-1,171
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_jindoruntimes.yaml

+1,981-1,823
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_juicefsruntimes.yaml

+2,104-1,915
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_thinruntimeprofiles.yaml

+1,195-1,037
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_thinruntimes.yaml

+2,148-1,992
Large diffs are not rendered by default.

charts/fluid/fluid/crds/data.fluid.io_vineyardruntimes.yaml

+2,056-1,850
Large diffs are not rendered by default.

cmd/alluxio/app/alluxio.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
ctrl "sigs.k8s.io/controller-runtime"
4040
"sigs.k8s.io/controller-runtime/pkg/controller"
4141
"sigs.k8s.io/controller-runtime/pkg/log/zap"
42+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4243
)
4344

4445
var (
@@ -114,13 +115,15 @@ func handle() {
114115

115116
utils.NewPprofServer(setupLog, pprofAddr, development)
116117

118+
// the default webhook server port is 9443, no need to set
117119
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
118-
Scheme: scheme,
119-
MetricsBindAddress: metricsAddr,
120+
Scheme: scheme,
121+
Metrics: metricsserver.Options{
122+
BindAddress: metricsAddr,
123+
},
120124
LeaderElection: enableLeaderElection,
121125
LeaderElectionNamespace: leaderElectionNamespace,
122126
LeaderElectionID: "alluxio.data.fluid.io",
123-
Port: 9443,
124127
NewClient: controllers.NewFluidControllerClient,
125128
})
126129
if err != nil {

cmd/csi/app/csi.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"k8s.io/apimachinery/pkg/runtime"
3838
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3939
ctrl "sigs.k8s.io/controller-runtime"
40+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4041
)
4142

4243
var (
@@ -101,10 +102,12 @@ func handle() {
101102
newPprofServer(pprofAddr)
102103
}
103104

105+
// the default webhook server port is 9443, no need to set
104106
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
105-
Scheme: scheme,
106-
MetricsBindAddress: metricsAddr,
107-
Port: 9443,
107+
Scheme: scheme,
108+
Metrics: metricsserver.Options{
109+
BindAddress: metricsAddr,
110+
},
108111
})
109112

110113
if err != nil {

cmd/dataset/app/dataset.go

+21-16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package app
1818

1919
import (
2020
"os"
21+
"sigs.k8s.io/controller-runtime/pkg/client"
2122
"time"
2223

2324
"github.com/spf13/cobra"
@@ -33,6 +34,7 @@ import (
3334
"sigs.k8s.io/controller-runtime/pkg/cache"
3435
"sigs.k8s.io/controller-runtime/pkg/controller"
3536
"sigs.k8s.io/controller-runtime/pkg/log/zap"
37+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3638

3739
"github.com/fluid-cloudnative/fluid"
3840
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
@@ -121,14 +123,16 @@ func handle() {
121123

122124
utils.NewPprofServer(setupLog, pprofAddr, development)
123125

126+
// the default webhook server port is 9443, no need to set
124127
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
125-
Scheme: scheme,
126-
MetricsBindAddress: metricsAddr,
128+
Scheme: scheme,
129+
Metrics: metricsserver.Options{
130+
BindAddress: metricsAddr,
131+
},
127132
LeaderElection: enableLeaderElection,
128133
LeaderElectionNamespace: leaderElectionNamespace,
129134
LeaderElectionID: "dataset.data.fluid.io",
130-
Port: 9443,
131-
NewCache: NewCache(scheme),
135+
Cache: NewCacheOptions(),
132136
NewClient: controllers.NewFluidControllerClient,
133137
})
134138
if err != nil {
@@ -232,21 +236,22 @@ func handle() {
232236
}
233237
}
234238

235-
func NewCache(scheme *runtime.Scheme) cache.NewCacheFunc {
236-
selectors := make(cache.SelectorsByObject, 1)
239+
func NewCacheOptions() cache.Options {
240+
var cronJobKey client.Object
237241

238242
if compatibility.IsBatchV1CronJobSupported() {
239-
selectors[&batchv1.CronJob{}] = cache.ObjectSelector{Label: labels.SelectorFromSet(labels.Set{
240-
common.JobPolicy: common.CronPolicy,
241-
})}
243+
cronJobKey = &batchv1.CronJob{}
242244
} else {
243-
selectors[&batchv1beta1.CronJob{}] = cache.ObjectSelector{Label: labels.SelectorFromSet(labels.Set{
244-
common.JobPolicy: common.CronPolicy,
245-
})}
245+
cronJobKey = &batchv1beta1.CronJob{}
246246
}
247247

248-
return cache.BuilderWithOptions(cache.Options{
249-
Scheme: scheme,
250-
SelectorsByObject: selectors,
251-
})
248+
return cache.Options{
249+
ByObject: map[client.Object]cache.ByObject{
250+
cronJobKey: {
251+
Label: labels.SelectorFromSet(labels.Set{
252+
common.JobPolicy: common.CronPolicy,
253+
}),
254+
},
255+
},
256+
}
252257
}

cmd/efc/app/efc.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
ctrl "sigs.k8s.io/controller-runtime"
3535
"sigs.k8s.io/controller-runtime/pkg/controller"
3636
"sigs.k8s.io/controller-runtime/pkg/log/zap"
37+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3738

3839
"github.com/fluid-cloudnative/fluid"
3940
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
@@ -113,13 +114,15 @@ func handle() {
113114

114115
utils.NewPprofServer(setupLog, pprofAddr, development)
115116

117+
// the default webhook server port is 9443, no need to set
116118
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
117-
Scheme: scheme,
118-
MetricsBindAddress: metricsAddr,
119+
Scheme: scheme,
120+
Metrics: metricsserver.Options{
121+
BindAddress: metricsAddr,
122+
},
119123
LeaderElection: enableLeaderElection,
120124
LeaderElectionNamespace: leaderElectionNamespace,
121125
LeaderElectionID: "efc.data.fluid.io",
122-
Port: 9443,
123126
NewClient: controllers.NewFluidControllerClient,
124127
})
125128
if err != nil {

cmd/fluidapp/app/fluidapp.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ package app
1818

1919
import (
2020
"github.com/fluid-cloudnative/fluid/pkg/common"
21+
2122
"github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/fluidapp/dataflowaffinity"
2223
"github.com/fluid-cloudnative/fluid/pkg/dataflow"
2324
utilfeature "github.com/fluid-cloudnative/fluid/pkg/utils/feature"
2425
batchv1 "k8s.io/api/batch/v1"
26+
2527
"k8s.io/apimachinery/pkg/labels"
2628
"os"
2729
"sigs.k8s.io/controller-runtime/pkg/cache"
30+
"sigs.k8s.io/controller-runtime/pkg/client"
2831

2932
"github.com/fluid-cloudnative/fluid"
3033
"github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/fluidapp"
@@ -38,6 +41,7 @@ import (
3841
ctrl "sigs.k8s.io/controller-runtime"
3942
"sigs.k8s.io/controller-runtime/pkg/controller"
4043
"sigs.k8s.io/controller-runtime/pkg/log/zap"
44+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4145
)
4246

4347
var (
@@ -91,14 +95,16 @@ func handle() {
9195

9296
utils.NewPprofServer(setupLog, pprofAddr, development)
9397

98+
// the default webhook server port is 9443, no need to set
9499
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
95-
Scheme: scheme,
96-
MetricsBindAddress: metricsAddr,
100+
Scheme: scheme,
101+
Metrics: metricsserver.Options{
102+
BindAddress: metricsAddr,
103+
},
97104
LeaderElection: enableLeaderElection,
98105
LeaderElectionNamespace: leaderElectionNamespace,
99106
LeaderElectionID: "fluidapp.data.fluid.io",
100-
Port: 9443,
101-
NewCache: NewCache(scheme),
107+
Cache: newCacheOptions(),
102108
})
103109
if err != nil {
104110
setupLog.Error(err, "unable to start fluid app manager")
@@ -135,10 +141,9 @@ func handle() {
135141
}
136142
}
137143

138-
func NewCache(scheme *runtime.Scheme) cache.NewCacheFunc {
144+
func newCacheOptions() cache.Options {
139145
options := cache.Options{
140-
Scheme: scheme,
141-
SelectorsByObject: cache.SelectorsByObject{
146+
ByObject: map[client.Object]cache.ByObject{
142147
&corev1.Pod{}: {
143148
Label: labels.SelectorFromSet(labels.Set{
144149
// watch pods managed by fluid, like data operation pods, serverless app pods.
@@ -148,13 +153,13 @@ func NewCache(scheme *runtime.Scheme) cache.NewCacheFunc {
148153
},
149154
}
150155
if dataflow.Enabled(dataflow.DataflowAffinity) {
151-
options.SelectorsByObject[&batchv1.Job{}] = cache.ObjectSelector{
156+
options.ByObject[&batchv1.Job{}] = cache.ByObject{
152157
// watch data operation job
153158
Label: labels.SelectorFromSet(labels.Set{
154159
// only data operations create job resource and the jobs created by cronjob do not have this label.
155160
common.LabelAnnotationManagedBy: common.Fluid,
156161
}),
157162
}
158163
}
159-
return cache.BuilderWithOptions(options)
164+
return options
160165
}

cmd/goosefs/app/goosefs.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
ctrl "sigs.k8s.io/controller-runtime"
3535
"sigs.k8s.io/controller-runtime/pkg/controller"
3636
"sigs.k8s.io/controller-runtime/pkg/log/zap"
37+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3738
)
3839

3940
var (
@@ -98,13 +99,15 @@ func handle() {
9899

99100
utils.NewPprofServer(setupLog, pprofAddr, development)
100101

102+
// the default webhook server port is 9443, no need to set
101103
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
102-
Scheme: scheme,
103-
MetricsBindAddress: metricsAddr,
104+
Scheme: scheme,
105+
Metrics: metricsserver.Options{
106+
BindAddress: metricsAddr,
107+
},
104108
LeaderElection: enableLeaderElection,
105109
LeaderElectionNamespace: leaderElectionNamespace,
106110
LeaderElectionID: "goosefs.data.fluid.io",
107-
Port: 9443,
108111
})
109112
if err != nil {
110113
setupLog.Error(err, "unable to start goosefsruntime manager")

cmd/jindo/app/jindo.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
ctrl "sigs.k8s.io/controller-runtime"
4242
"sigs.k8s.io/controller-runtime/pkg/controller"
4343
"sigs.k8s.io/controller-runtime/pkg/log/zap"
44+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4445
)
4546

4647
var (
@@ -121,13 +122,15 @@ func handle() {
121122

122123
utils.NewPprofServer(setupLog, pprofAddr, development)
123124

125+
// the default webhook server port is 9443, no need to set
124126
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
125-
Scheme: scheme,
126-
MetricsBindAddress: metricsAddr,
127+
Scheme: scheme,
128+
Metrics: metricsserver.Options{
129+
BindAddress: metricsAddr,
130+
},
127131
LeaderElection: enableLeaderElection,
128132
LeaderElectionNamespace: leaderElectionNamespace,
129133
LeaderElectionID: "jindo.data.fluid.io",
130-
Port: 9443,
131134
NewClient: controllers.NewFluidControllerClient,
132135
})
133136
if err != nil {

cmd/juicefs/app/juicefs.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import (
3030
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3131
"k8s.io/client-go/rest"
3232
ctrl "sigs.k8s.io/controller-runtime"
33-
"sigs.k8s.io/controller-runtime/pkg/cache"
3433
"sigs.k8s.io/controller-runtime/pkg/client"
3534
"sigs.k8s.io/controller-runtime/pkg/controller"
3635
"sigs.k8s.io/controller-runtime/pkg/log/zap"
36+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3737

3838
"github.com/fluid-cloudnative/fluid/pkg/controllers"
3939
"github.com/fluid-cloudnative/fluid/pkg/ddc/base/portallocator"
@@ -121,20 +121,21 @@ func handle() {
121121

122122
utils.NewPprofServer(setupLog, pprofAddr, development)
123123

124-
NewControllerClient := func(cache cache.Cache, config *rest.Config, options client.Options, uncachedObjects ...client.Object) (client.Client, error) {
125-
return controllers.NewFluidControllerClient(cache, config, options,
126-
append(uncachedObjects, &rbacv1.RoleBinding{}, &rbacv1.Role{}, &corev1.ServiceAccount{})...,
127-
)
124+
NewControllerClient := func(config *rest.Config, options client.Options) (client.Client, error) {
125+
options.Cache.DisableFor = append(options.Cache.DisableFor, &rbacv1.RoleBinding{}, &rbacv1.Role{}, &corev1.ServiceAccount{})
126+
return controllers.NewFluidControllerClient(config, options)
128127
}
129128

129+
// the default webhook server port is 9443, no need to set
130130
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
131-
Scheme: scheme,
132-
MetricsBindAddress: metricsAddr,
131+
Scheme: scheme,
132+
Metrics: metricsserver.Options{
133+
BindAddress: metricsAddr,
134+
},
133135
LeaderElection: enableLeaderElection,
134136
LeaderElectionNamespace: leaderElectionNamespace,
135137
LeaderElectionID: "juicefs.data.fluid.io",
136-
Port: 9443,
137-
NewCache: juicefsctl.NewCache(scheme),
138+
Cache: juicefsctl.NewCacheOption(),
138139
NewClient: NewControllerClient,
139140
})
140141
if err != nil {

0 commit comments

Comments
 (0)