Skip to content

Commit

Permalink
Upgrade controller runtime to v0.17.5 and k8s api to v0.29.5 (#4160)
Browse files Browse the repository at this point in the history
* upgrade controller runtime version to 0.17.5

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix go mod

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix pointer to ptr

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* update from master

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix api change

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix go mod conflict

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* empty line to trigger new test

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* fix comment

Signed-off-by: xliuqq <xlzq1992@gmail.com>

* order import and add todo for offset

Signed-off-by: xliuqq <xlzq1992@gmail.com>

---------

Signed-off-by: xliuqq <xlzq1992@gmail.com>
  • Loading branch information
xliuqq authored Jul 31, 2024
1 parent 81fafee commit 6a65a9e
Show file tree
Hide file tree
Showing 1,067 changed files with 125,505 additions and 77,732 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ docker-buildx-all-push: pre-setup ${DOCKER_BUILDX_PUSH}

# find or download controller-gen
# download controller-gen if necessary
# controller-gen@v0.12.1 comply with k8s.io/api v0.26.x
# controller-gen@v0.14.0 comply with k8s.io/api v0.29.x
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
Expand All @@ -340,7 +340,7 @@ ifeq (, $(shell which controller-gen))
cd $$CONTROLLER_GEN_TMP_DIR ;\
export GO111MODULE=on ;\
go mod init tmp ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.1 ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand Down
6 changes: 0 additions & 6 deletions api/v1alpha1/openapi_generated.go

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

1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

4,031 changes: 2,119 additions & 1,912 deletions charts/fluid/fluid/crds/data.fluid.io_alluxioruntimes.yaml

Large diffs are not rendered by default.

169 changes: 83 additions & 86 deletions charts/fluid/fluid/crds/data.fluid.io_databackups.yaml

Large diffs are not rendered by default.

1,070 changes: 566 additions & 504 deletions charts/fluid/fluid/crds/data.fluid.io_dataloads.yaml

Large diffs are not rendered by default.

1,076 changes: 569 additions & 507 deletions charts/fluid/fluid/crds/data.fluid.io_datamigrates.yaml

Large diffs are not rendered by default.

9,102 changes: 4,435 additions & 4,667 deletions charts/fluid/fluid/crds/data.fluid.io_dataprocesses.yaml

Large diffs are not rendered by default.

190 changes: 99 additions & 91 deletions charts/fluid/fluid/crds/data.fluid.io_datasets.yaml

Large diffs are not rendered by default.

2,101 changes: 1,068 additions & 1,033 deletions charts/fluid/fluid/crds/data.fluid.io_efcruntimes.yaml

Large diffs are not rendered by default.

2,413 changes: 1,242 additions & 1,171 deletions charts/fluid/fluid/crds/data.fluid.io_goosefsruntimes.yaml

Large diffs are not rendered by default.

3,804 changes: 1,981 additions & 1,823 deletions charts/fluid/fluid/crds/data.fluid.io_jindoruntimes.yaml

Large diffs are not rendered by default.

4,019 changes: 2,104 additions & 1,915 deletions charts/fluid/fluid/crds/data.fluid.io_juicefsruntimes.yaml

Large diffs are not rendered by default.

2,232 changes: 1,195 additions & 1,037 deletions charts/fluid/fluid/crds/data.fluid.io_thinruntimeprofiles.yaml

Large diffs are not rendered by default.

4,140 changes: 2,148 additions & 1,992 deletions charts/fluid/fluid/crds/data.fluid.io_thinruntimes.yaml

Large diffs are not rendered by default.

3,906 changes: 2,056 additions & 1,850 deletions charts/fluid/fluid/crds/data.fluid.io_vineyardruntimes.yaml

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions cmd/alluxio/app/alluxio.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

var (
Expand Down Expand Up @@ -114,13 +115,15 @@ func handle() {

utils.NewPprofServer(setupLog, pprofAddr, development)

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "alluxio.data.fluid.io",
Port: 9443,
NewClient: controllers.NewFluidControllerClient,
})
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions cmd/csi/app/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

var (
Expand Down Expand Up @@ -101,10 +102,12 @@ func handle() {
newPprofServer(pprofAddr)
}

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
})

if err != nil {
Expand Down
37 changes: 21 additions & 16 deletions cmd/dataset/app/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package app

import (
"os"
"sigs.k8s.io/controller-runtime/pkg/client"
"time"

"github.com/spf13/cobra"
Expand All @@ -33,6 +34,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/fluid-cloudnative/fluid"
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
Expand Down Expand Up @@ -121,14 +123,16 @@ func handle() {

utils.NewPprofServer(setupLog, pprofAddr, development)

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "dataset.data.fluid.io",
Port: 9443,
NewCache: NewCache(scheme),
Cache: NewCacheOptions(),
NewClient: controllers.NewFluidControllerClient,
})
if err != nil {
Expand Down Expand Up @@ -232,21 +236,22 @@ func handle() {
}
}

func NewCache(scheme *runtime.Scheme) cache.NewCacheFunc {
selectors := make(cache.SelectorsByObject, 1)
func NewCacheOptions() cache.Options {
var cronJobKey client.Object

if compatibility.IsBatchV1CronJobSupported() {
selectors[&batchv1.CronJob{}] = cache.ObjectSelector{Label: labels.SelectorFromSet(labels.Set{
common.JobPolicy: common.CronPolicy,
})}
cronJobKey = &batchv1.CronJob{}
} else {
selectors[&batchv1beta1.CronJob{}] = cache.ObjectSelector{Label: labels.SelectorFromSet(labels.Set{
common.JobPolicy: common.CronPolicy,
})}
cronJobKey = &batchv1beta1.CronJob{}
}

return cache.BuilderWithOptions(cache.Options{
Scheme: scheme,
SelectorsByObject: selectors,
})
return cache.Options{
ByObject: map[client.Object]cache.ByObject{
cronJobKey: {
Label: labels.SelectorFromSet(labels.Set{
common.JobPolicy: common.CronPolicy,
}),
},
},
}
}
9 changes: 6 additions & 3 deletions cmd/efc/app/efc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/fluid-cloudnative/fluid"
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
Expand Down Expand Up @@ -113,13 +114,15 @@ func handle() {

utils.NewPprofServer(setupLog, pprofAddr, development)

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "efc.data.fluid.io",
Port: 9443,
NewClient: controllers.NewFluidControllerClient,
})
if err != nil {
Expand Down
23 changes: 14 additions & 9 deletions cmd/fluidapp/app/fluidapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ package app

import (
"github.com/fluid-cloudnative/fluid/pkg/common"

"github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/fluidapp/dataflowaffinity"
"github.com/fluid-cloudnative/fluid/pkg/dataflow"
utilfeature "github.com/fluid-cloudnative/fluid/pkg/utils/feature"
batchv1 "k8s.io/api/batch/v1"

"k8s.io/apimachinery/pkg/labels"
"os"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/fluid-cloudnative/fluid"
"github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/fluidapp"
Expand All @@ -38,6 +41,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

var (
Expand Down Expand Up @@ -91,14 +95,16 @@ func handle() {

utils.NewPprofServer(setupLog, pprofAddr, development)

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "fluidapp.data.fluid.io",
Port: 9443,
NewCache: NewCache(scheme),
Cache: newCacheOptions(),
})
if err != nil {
setupLog.Error(err, "unable to start fluid app manager")
Expand Down Expand Up @@ -135,10 +141,9 @@ func handle() {
}
}

func NewCache(scheme *runtime.Scheme) cache.NewCacheFunc {
func newCacheOptions() cache.Options {
options := cache.Options{
Scheme: scheme,
SelectorsByObject: cache.SelectorsByObject{
ByObject: map[client.Object]cache.ByObject{
&corev1.Pod{}: {
Label: labels.SelectorFromSet(labels.Set{
// watch pods managed by fluid, like data operation pods, serverless app pods.
Expand All @@ -148,13 +153,13 @@ func NewCache(scheme *runtime.Scheme) cache.NewCacheFunc {
},
}
if dataflow.Enabled(dataflow.DataflowAffinity) {
options.SelectorsByObject[&batchv1.Job{}] = cache.ObjectSelector{
options.ByObject[&batchv1.Job{}] = cache.ByObject{
// watch data operation job
Label: labels.SelectorFromSet(labels.Set{
// only data operations create job resource and the jobs created by cronjob do not have this label.
common.LabelAnnotationManagedBy: common.Fluid,
}),
}
}
return cache.BuilderWithOptions(options)
return options
}
9 changes: 6 additions & 3 deletions cmd/goosefs/app/goosefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

var (
Expand Down Expand Up @@ -98,13 +99,15 @@ func handle() {

utils.NewPprofServer(setupLog, pprofAddr, development)

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "goosefs.data.fluid.io",
Port: 9443,
})
if err != nil {
setupLog.Error(err, "unable to start goosefsruntime manager")
Expand Down
9 changes: 6 additions & 3 deletions cmd/jindo/app/jindo.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

var (
Expand Down Expand Up @@ -121,13 +122,15 @@ func handle() {

utils.NewPprofServer(setupLog, pprofAddr, development)

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "jindo.data.fluid.io",
Port: 9443,
NewClient: controllers.NewFluidControllerClient,
})
if err != nil {
Expand Down
19 changes: 10 additions & 9 deletions cmd/juicefs/app/juicefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

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

utils.NewPprofServer(setupLog, pprofAddr, development)

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

// the default webhook server port is 9443, no need to set
mgr, err := ctrl.NewManager(controllers.GetConfigOrDieWithQPSAndBurst(kubeClientQPS, kubeClientBurst), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
LeaderElection: enableLeaderElection,
LeaderElectionNamespace: leaderElectionNamespace,
LeaderElectionID: "juicefs.data.fluid.io",
Port: 9443,
NewCache: juicefsctl.NewCache(scheme),
Cache: juicefsctl.NewCacheOption(),
NewClient: NewControllerClient,
})
if err != nil {
Expand Down
Loading

0 comments on commit 6a65a9e

Please sign in to comment.