Skip to content

Commit 4270448

Browse files
committed
Bump cluster api to v1.9.4 and refactor the code accordingly
1. Bumped cluster api to v1.9.4 2. Refactored deprecated code a) Added scheme to `predicates.ResourceNotPaused` b) Changed parameter in `controller.TypedController[reconcile.Request].Watch()`
1 parent 3344ecd commit 4270448

File tree

4 files changed

+201
-161
lines changed

4 files changed

+201
-161
lines changed

controllers/maascluster_controller.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22-
"k8s.io/apimachinery/pkg/runtime"
2322
"time"
2423

24+
"k8s.io/apimachinery/pkg/runtime"
25+
2526
"github.com/go-logr/logr"
2627
"github.com/pkg/errors"
2728
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -295,22 +296,24 @@ func (r *MaasClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
295296
&infrav1beta1.MaasMachine{},
296297
handler.EnqueueRequestsFromMapFunc(r.controlPlaneMachineToCluster),
297298
).
298-
WithEventFilter(predicates.ResourceNotPaused(r.Log)).
299+
WithEventFilter(predicates.ResourceNotPaused(mgr.GetScheme(), r.Log)).
299300
Build(r)
300301
if err != nil {
301302
return err
302303
}
303304
if err := c.Watch(
304-
&source.Channel{Source: r.GenericEventChannel},
305-
&handler.EnqueueRequestForObject{},
305+
source.Channel(r.GenericEventChannel, &handler.EnqueueRequestForObject{}),
306306
); err != nil {
307307
return err
308308
}
309-
return c.Watch(
310-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
311-
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(context.Background(), infrav1beta1.GroupVersion.WithKind("MaasCluster"), mgr.GetClient(), &infrav1beta1.MaasCluster{})),
312-
predicates.ClusterUnpaused(r.Log),
313-
)
309+
return c.Watch(source.Kind[client.Object](
310+
mgr.GetCache(),
311+
&clusterv1.Cluster{},
312+
handler.EnqueueRequestsFromMapFunc(
313+
util.ClusterToInfrastructureMapFunc(context.Background(), infrav1beta1.GroupVersion.WithKind("MaasCluster"), mgr.GetClient(), &infrav1beta1.MaasCluster{}),
314+
),
315+
predicates.ClusterUnpaused(mgr.GetScheme(), r.Log),
316+
))
314317
}
315318

316319
// controlPlaneMachineToCluster is a handler.ToRequestsFunc to be used

controllers/maasmachine_controller.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020
"context"
2121
"encoding/base64"
2222
"fmt"
23-
"k8s.io/apimachinery/pkg/runtime"
2423
"time"
2524

25+
"k8s.io/apimachinery/pkg/runtime"
26+
2627
"github.com/go-logr/logr"
2728
"github.com/pkg/errors"
2829
corev1 "k8s.io/api/core/v1"
@@ -463,16 +464,16 @@ func (r *MaasMachineReconciler) SetupWithManager(_ context.Context, mgr ctrl.Man
463464
&infrav1beta1.MaasCluster{},
464465
handler.EnqueueRequestsFromMapFunc(r.MaasClusterToMaasMachines),
465466
).
466-
WithEventFilter(predicates.ResourceNotPaused(r.Log)).
467+
WithEventFilter(predicates.ResourceNotPaused(mgr.GetScheme(), r.Log)).
467468
Build(r)
468469
if err != nil {
469470
return err
470471
}
471472
return c.Watch(
472-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
473-
handler.EnqueueRequestsFromMapFunc(clusterToMaasMachines),
474-
predicates.ClusterUnpausedAndInfrastructureReady(r.Log),
475-
)
473+
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
474+
handler.EnqueueRequestsFromMapFunc(clusterToMaasMachines),
475+
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), r.Log),
476+
))
476477
}
477478

478479
// MaasClusterToMaasMachines is a handler.ToRequestsFunc to be used to enqeue

go.mod

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
module github.com/spectrocloud/cluster-api-provider-maas
22

3-
go 1.21
3+
go 1.22.0
44

5-
toolchain go1.21.2
5+
toolchain go1.23.6
66

77
require (
8-
github.com/go-logr/logr v1.4.1
8+
github.com/go-logr/logr v1.4.2
99
github.com/golang/mock v1.6.0
10-
github.com/google/uuid v1.4.0
10+
github.com/google/uuid v1.6.0
1111
github.com/onsi/ginkgo v1.16.5
12-
github.com/onsi/gomega v1.32.0
12+
github.com/onsi/gomega v1.36.0
1313
github.com/pkg/errors v0.9.1
1414
github.com/spectrocloud/maas-client-go v0.0.1-beta1.0.20230830132549-2f7491722359
1515
github.com/spf13/pflag v1.0.5
16-
k8s.io/api v0.29.3
17-
k8s.io/apiextensions-apiserver v0.29.3
18-
k8s.io/apimachinery v0.29.3
19-
k8s.io/client-go v0.29.3
20-
k8s.io/klog/v2 v2.110.1
21-
k8s.io/utils v0.0.0-20231127182322-b307cd553661
22-
sigs.k8s.io/cluster-api v1.7.2
23-
sigs.k8s.io/controller-runtime v0.17.3
16+
k8s.io/api v0.31.3
17+
k8s.io/apiextensions-apiserver v0.31.3
18+
k8s.io/apimachinery v0.31.3
19+
k8s.io/client-go v0.31.3
20+
k8s.io/klog/v2 v2.130.1
21+
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
22+
sigs.k8s.io/cluster-api v1.9.4
23+
sigs.k8s.io/controller-runtime v0.19.4
2424
)
2525

2626
require (
2727
github.com/MakeNowJust/heredoc v1.0.0 // indirect
2828
github.com/beorn7/perks v1.0.1 // indirect
2929
github.com/blang/semver/v4 v4.0.0 // indirect
30-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
30+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3131
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
32-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
33-
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
32+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
3433
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
3534
github.com/fsnotify/fsnotify v1.7.0 // indirect
35+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
3636
github.com/go-openapi/jsonpointer v0.19.6 // indirect
3737
github.com/go-openapi/jsonreference v0.20.2 // indirect
38-
github.com/go-openapi/swag v0.22.3 // indirect
39-
github.com/gobuffalo/flect v1.0.2 // indirect
38+
github.com/go-openapi/swag v0.22.4 // indirect
39+
github.com/gobuffalo/flect v1.0.3 // indirect
4040
github.com/gogo/protobuf v1.3.2 // indirect
4141
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4242
github.com/golang/protobuf v1.5.4 // indirect
@@ -47,36 +47,36 @@ require (
4747
github.com/josharian/intern v1.0.0 // indirect
4848
github.com/json-iterator/go v1.1.12 // indirect
4949
github.com/mailru/easyjson v0.7.7 // indirect
50-
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
5150
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5251
github.com/modern-go/reflect2 v1.0.2 // indirect
5352
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5453
github.com/nxadm/tail v1.4.8 // indirect
55-
github.com/prometheus/client_golang v1.18.0 // indirect
56-
github.com/prometheus/client_model v0.5.0 // indirect
57-
github.com/prometheus/common v0.45.0 // indirect
58-
github.com/prometheus/procfs v0.12.0 // indirect
59-
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
60-
golang.org/x/net v0.23.0 // indirect
61-
golang.org/x/oauth2 v0.18.0 // indirect
62-
golang.org/x/sys v0.18.0 // indirect
63-
golang.org/x/term v0.18.0 // indirect
64-
golang.org/x/text v0.14.0 // indirect
54+
github.com/prometheus/client_golang v1.19.1 // indirect
55+
github.com/prometheus/client_model v0.6.1 // indirect
56+
github.com/prometheus/common v0.55.0 // indirect
57+
github.com/prometheus/procfs v0.15.1 // indirect
58+
github.com/x448/float16 v0.8.4 // indirect
59+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
60+
golang.org/x/net v0.33.0 // indirect
61+
golang.org/x/oauth2 v0.24.0 // indirect
62+
golang.org/x/sys v0.28.0 // indirect
63+
golang.org/x/term v0.27.0 // indirect
64+
golang.org/x/text v0.21.0 // indirect
6565
golang.org/x/time v0.5.0 // indirect
6666
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
67-
google.golang.org/appengine v1.6.7 // indirect
68-
google.golang.org/protobuf v1.33.0 // indirect
67+
google.golang.org/protobuf v1.35.1 // indirect
68+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
6969
gopkg.in/inf.v0 v0.9.1 // indirect
7070
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
7171
gopkg.in/yaml.v2 v2.4.0 // indirect
7272
gopkg.in/yaml.v3 v3.0.1 // indirect
73-
k8s.io/cluster-bootstrap v0.29.3 // indirect
74-
k8s.io/component-base v0.29.3 // indirect
75-
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
73+
k8s.io/cluster-bootstrap v0.31.3 // indirect
74+
k8s.io/component-base v0.31.3 // indirect
75+
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
7676
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
7777
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
7878
sigs.k8s.io/yaml v1.4.0 // indirect
7979
)
8080

8181
//github.com/go-logr/logr v1.2.0 => github.com/go-logr/logr v0.4.0
82-
replace github.com/prometheus/common v0.32.1 => github.com/prometheus/common v0.26.0
82+
// replace github.com/prometheus/common v0.32.1 => github.com/prometheus/common v0.26.0

0 commit comments

Comments
 (0)