Skip to content

Commit 46f9186

Browse files
committed
Upgrade CAPI to 1.8
1 parent 37348bf commit 46f9186

File tree

15 files changed

+388
-387
lines changed

15 files changed

+388
-387
lines changed

.golangci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ linters:
3232

3333
run:
3434
issues-exit-code: 1
35-
skip-dirs:
36-
- pkg/mocks
37-
- test
35+
tests: false
3836

3937
issues:
4038
# Excluding configuration per-path, per-linter, per-text and per-source
@@ -43,3 +41,6 @@ issues:
4341
- path: _test\.go
4442
linters:
4543
- gosec
44+
exclude-dirs:
45+
- pkg/mocks
46+
- test

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ delete-kind-cluster:
244244
kind delete cluster --name $(KIND_CLUSTER_NAME)
245245

246246
cluster-api: ## Clone cluster-api repository for tilt use.
247-
git clone --branch v1.7.9 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
247+
git clone --branch v1.8.11 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
248248

249249
cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
250250
cp ./hack/tilt-settings.json cluster-api

config/manager/manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ spec:
3939
privileged: false
4040
runAsUser: 65532
4141
runAsGroup: 65532
42+
terminationMessagePolicy: FallbackToLogsOnError
4243
livenessProbe:
4344
httpGet:
4445
path: /healthz

controllers/cloudstackcluster_controller.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
"reflect"
2323

2424
ctrl "sigs.k8s.io/controller-runtime"
25+
"sigs.k8s.io/controller-runtime/pkg/builder"
2526
"sigs.k8s.io/controller-runtime/pkg/controller"
2627
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2728
"sigs.k8s.io/controller-runtime/pkg/event"
2829
"sigs.k8s.io/controller-runtime/pkg/handler"
2930
"sigs.k8s.io/controller-runtime/pkg/predicate"
30-
"sigs.k8s.io/controller-runtime/pkg/source"
3131

3232
"github.com/pkg/errors"
3333
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
@@ -159,10 +159,9 @@ func (r *CloudStackClusterReconciliationRunner) ReconcileDelete() (ctrl.Result,
159159
func (reconciler *CloudStackClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opts controller.Options) error {
160160
log := ctrl.LoggerFrom(ctx)
161161

162-
controller, err := ctrl.NewControllerManagedBy(mgr).
162+
b := ctrl.NewControllerManagedBy(mgr).
163163
WithOptions(opts).
164-
For(&infrav1.CloudStackCluster{}).
165-
WithEventFilter(
164+
For(&infrav1.CloudStackCluster{}, builder.WithPredicates(
166165
predicate.Funcs{
167166
UpdateFunc: func(e event.UpdateEvent) bool {
168167
oldCluster := e.ObjectOld.(*infrav1.CloudStackCluster).DeepCopy()
@@ -183,18 +182,20 @@ func (reconciler *CloudStackClusterReconciler) SetupWithManager(ctx context.Cont
183182
return !reflect.DeepEqual(oldCluster, newCluster)
184183
},
185184
},
186-
).Build(reconciler)
187-
if err != nil {
188-
return errors.Wrap(err, "building CloudStackCluster controller")
189-
}
185+
),
186+
)
190187

191188
// Add a watch on CAPI Cluster objects for unpause and ready events.
192-
if err = controller.Watch(
193-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
189+
b = b.Watches(
190+
&clusterv1.Cluster{},
194191
handler.EnqueueRequestsFromMapFunc(
195192
util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("CloudStackCluster"), mgr.GetClient(), &infrav1.CloudStackCluster{})),
196-
predicates.ClusterUnpaused(log),
197-
); err != nil {
193+
builder.WithPredicates(
194+
predicates.ClusterUnpaused(log),
195+
),
196+
)
197+
198+
if err := b.Complete(reconciler); err != nil {
198199
return errors.Wrap(err, "building CloudStackCluster controller")
199200
}
200201

controllers/cloudstackmachine_controller.go

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ import (
3232
"sigs.k8s.io/cluster-api/util"
3333
"sigs.k8s.io/cluster-api/util/predicates"
3434
ctrl "sigs.k8s.io/controller-runtime"
35+
"sigs.k8s.io/controller-runtime/pkg/builder"
3536
"sigs.k8s.io/controller-runtime/pkg/client"
3637
"sigs.k8s.io/controller-runtime/pkg/controller"
3738
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3839
"sigs.k8s.io/controller-runtime/pkg/event"
3940
"sigs.k8s.io/controller-runtime/pkg/handler"
4041
"sigs.k8s.io/controller-runtime/pkg/predicate"
41-
"sigs.k8s.io/controller-runtime/pkg/source"
4242

4343
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
4444
"sigs.k8s.io/cluster-api-provider-cloudstack/controllers/utils"
@@ -362,62 +362,59 @@ func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.R
362362
func (reconciler *CloudStackMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opts controller.Options) error {
363363
log := ctrl.LoggerFrom(ctx)
364364

365-
controller, err := ctrl.NewControllerManagedBy(mgr).
365+
b := ctrl.NewControllerManagedBy(mgr).
366366
WithOptions(opts).
367-
For(&infrav1.CloudStackMachine{}).
368-
WithEventFilter(
369-
predicate.Funcs{
370-
UpdateFunc: func(e event.UpdateEvent) bool {
371-
oldMachine := e.ObjectOld.(*infrav1.CloudStackMachine).DeepCopy()
372-
newMachine := e.ObjectNew.(*infrav1.CloudStackMachine).DeepCopy()
373-
// Ignore resource version because they are unique
374-
oldMachine.ObjectMeta.ResourceVersion = ""
375-
newMachine.ObjectMeta.ResourceVersion = ""
376-
// Ignore generation because it's not used in reconcile
377-
oldMachine.ObjectMeta.Generation = 0
378-
newMachine.ObjectMeta.Generation = 0
379-
// Ignore finalizers updates
380-
oldMachine.ObjectMeta.Finalizers = nil
381-
newMachine.ObjectMeta.Finalizers = nil
382-
// Ignore ManagedFields because they are mirror of ObjectMeta
383-
oldMachine.ManagedFields = nil
384-
newMachine.ManagedFields = nil
385-
// Ignore incremental status updates
386-
oldMachine.Status = infrav1.CloudStackMachineStatus{}
387-
newMachine.Status = infrav1.CloudStackMachineStatus{}
388-
// Ignore provide ID
389-
oldMachine.Spec.ProviderID = nil
390-
newMachine.Spec.ProviderID = nil
391-
// Ignore instance ID
392-
oldMachine.Spec.InstanceID = nil
393-
newMachine.Spec.InstanceID = nil
394-
395-
return !reflect.DeepEqual(oldMachine, newMachine)
367+
For(&infrav1.CloudStackMachine{},
368+
builder.WithPredicates(
369+
predicate.Funcs{
370+
UpdateFunc: func(e event.UpdateEvent) bool {
371+
oldMachine := e.ObjectOld.(*infrav1.CloudStackMachine).DeepCopy()
372+
newMachine := e.ObjectNew.(*infrav1.CloudStackMachine).DeepCopy()
373+
// Ignore resource version because they are unique
374+
oldMachine.ObjectMeta.ResourceVersion = ""
375+
newMachine.ObjectMeta.ResourceVersion = ""
376+
// Ignore generation because it's not used in reconcile
377+
oldMachine.ObjectMeta.Generation = 0
378+
newMachine.ObjectMeta.Generation = 0
379+
// Ignore finalizers updates
380+
oldMachine.ObjectMeta.Finalizers = nil
381+
newMachine.ObjectMeta.Finalizers = nil
382+
// Ignore ManagedFields because they are mirror of ObjectMeta
383+
oldMachine.ManagedFields = nil
384+
newMachine.ManagedFields = nil
385+
// Ignore incremental status updates
386+
oldMachine.Status = infrav1.CloudStackMachineStatus{}
387+
newMachine.Status = infrav1.CloudStackMachineStatus{}
388+
// Ignore provide ID
389+
oldMachine.Spec.ProviderID = nil
390+
newMachine.Spec.ProviderID = nil
391+
// Ignore instance ID
392+
oldMachine.Spec.InstanceID = nil
393+
newMachine.Spec.InstanceID = nil
394+
395+
return !reflect.DeepEqual(oldMachine, newMachine)
396+
},
396397
},
397-
},
398-
).Build(reconciler)
399-
if err != nil {
400-
return err
401-
}
398+
),
399+
)
402400

403401
// Watch CAPI machines for changes.
404402
// Queues a reconcile request for owned CloudStackMachine on change.
405403
// Used to update when bootstrap data becomes available.
406-
if err = controller.Watch(
407-
source.Kind(mgr.GetCache(), &clusterv1.Machine{}),
404+
b = b.Watches(
405+
&clusterv1.Machine{},
408406
handler.EnqueueRequestsFromMapFunc(
409407
util.MachineToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("CloudStackMachine"))),
410-
predicate.Funcs{
411-
UpdateFunc: func(e event.UpdateEvent) bool {
412-
oldMachine := e.ObjectOld.(*clusterv1.Machine)
413-
newMachine := e.ObjectNew.(*clusterv1.Machine)
414-
415-
return oldMachine.Spec.Bootstrap.DataSecretName == nil && newMachine.Spec.Bootstrap.DataSecretName != nil
416-
},
417-
},
418-
); err != nil {
419-
return err
420-
}
408+
builder.WithPredicates(
409+
predicate.Funcs{
410+
UpdateFunc: func(e event.UpdateEvent) bool {
411+
oldMachine := e.ObjectOld.(*clusterv1.Machine)
412+
newMachine := e.ObjectNew.(*clusterv1.Machine)
413+
414+
return oldMachine.Spec.Bootstrap.DataSecretName == nil && newMachine.Spec.Bootstrap.DataSecretName != nil
415+
},
416+
}),
417+
)
421418

422419
// Used below, this maps CAPI clusters to CAPC machines
423420
csMachineMapper, err := util.ClusterToTypedObjectsMapper(reconciler.K8sClient, &infrav1.CloudStackMachineList{}, mgr.GetScheme())
@@ -427,9 +424,16 @@ func (reconciler *CloudStackMachineReconciler) SetupWithManager(ctx context.Cont
427424

428425
reconciler.Recorder = mgr.GetEventRecorderFor("capc-machine-controller")
429426
// Add a watch on CAPI Cluster objects for unpause and ready events.
430-
return controller.Watch(
431-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
427+
b = b.Watches(
428+
&clusterv1.Cluster{},
432429
handler.EnqueueRequestsFromMapFunc(csMachineMapper),
433-
predicates.ClusterUnpausedAndInfrastructureReady(log),
430+
builder.WithPredicates(
431+
predicates.ClusterUnpausedAndInfrastructureReady(log)),
434432
)
433+
434+
if err := b.Complete(reconciler); err != nil {
435+
return errors.Wrap(err, "building CloudStackMachine controller")
436+
}
437+
438+
return nil
435439
}

go.mod

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
module sigs.k8s.io/cluster-api-provider-cloudstack
22

3-
go 1.22
3+
go 1.22.0
4+
5+
toolchain go1.22.12
46

57
require (
68
github.com/apache/cloudstack-go/v2 v2.16.1
79
github.com/go-logr/logr v1.4.2
810
github.com/golang/mock v1.6.0
911
github.com/hashicorp/go-multierror v1.1.1
1012
github.com/jellydator/ttlcache/v3 v3.2.0
11-
github.com/onsi/ginkgo/v2 v2.19.0
12-
github.com/onsi/gomega v1.33.1
13+
github.com/onsi/ginkgo/v2 v2.19.1
14+
github.com/onsi/gomega v1.34.0
1315
github.com/pkg/errors v0.9.1
1416
github.com/prometheus/client_golang v1.18.0
1517
github.com/smallfish/simpleyaml v0.1.0
1618
github.com/spf13/pflag v1.0.5
17-
golang.org/x/text v0.15.0
19+
golang.org/x/text v0.21.0
1820
gopkg.in/yaml.v3 v3.0.1
19-
k8s.io/api v0.29.3
20-
k8s.io/apimachinery v0.29.3
21-
k8s.io/client-go v0.29.3
22-
k8s.io/component-base v0.29.3
23-
k8s.io/klog/v2 v2.110.1
21+
k8s.io/api v0.30.3
22+
k8s.io/apimachinery v0.30.3
23+
k8s.io/client-go v0.30.3
24+
k8s.io/component-base v0.30.3
25+
k8s.io/klog/v2 v2.120.1
2426
k8s.io/utils v0.0.0-20231127182322-b307cd553661
25-
sigs.k8s.io/cluster-api v1.7.9
26-
sigs.k8s.io/controller-runtime v0.17.6
27+
sigs.k8s.io/cluster-api v1.8.11
28+
sigs.k8s.io/controller-runtime v0.18.7
2729
)
2830

2931
require (
@@ -35,7 +37,7 @@ require (
3537
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
3638
github.com/cespare/xxhash/v2 v2.2.0 // indirect
3739
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
38-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
40+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
3941
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
4042
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
4143
github.com/felixge/httpsnoop v1.0.4 // indirect
@@ -49,12 +51,12 @@ require (
4951
github.com/gogo/protobuf v1.3.2 // indirect
5052
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5153
github.com/golang/protobuf v1.5.4 // indirect
52-
github.com/google/cel-go v0.17.7 // indirect
54+
github.com/google/cel-go v0.17.8 // indirect
5355
github.com/google/gnostic-models v0.6.8 // indirect
5456
github.com/google/go-cmp v0.6.0 // indirect
5557
github.com/google/gofuzz v1.2.0 // indirect
5658
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
57-
github.com/google/uuid v1.4.0 // indirect
59+
github.com/google/uuid v1.6.0 // indirect
5860
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
5961
github.com/hashicorp/errwrap v1.0.0 // indirect
6062
github.com/imdario/mergo v0.3.13 // indirect
@@ -66,40 +68,39 @@ require (
6668
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6769
github.com/modern-go/reflect2 v1.0.2 // indirect
6870
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
69-
github.com/prometheus/client_model v0.5.0 // indirect
71+
github.com/prometheus/client_model v0.6.0 // indirect
7072
github.com/prometheus/common v0.45.0 // indirect
7173
github.com/prometheus/procfs v0.12.0 // indirect
72-
github.com/spf13/cobra v1.8.0 // indirect
74+
github.com/spf13/cobra v1.8.1 // indirect
7375
github.com/stoewer/go-strcase v1.2.0 // indirect
74-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0 // indirect
75-
go.opentelemetry.io/otel v1.20.0 // indirect
76+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
77+
go.opentelemetry.io/otel v1.24.0 // indirect
7678
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.20.0 // indirect
7779
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.20.0 // indirect
78-
go.opentelemetry.io/otel/metric v1.20.0 // indirect
80+
go.opentelemetry.io/otel/metric v1.24.0 // indirect
7981
go.opentelemetry.io/otel/sdk v1.20.0 // indirect
80-
go.opentelemetry.io/otel/trace v1.20.0 // indirect
82+
go.opentelemetry.io/otel/trace v1.24.0 // indirect
8183
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
8284
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
83-
golang.org/x/net v0.25.0 // indirect
84-
golang.org/x/oauth2 v0.18.0 // indirect
85-
golang.org/x/sync v0.7.0 // indirect
86-
golang.org/x/sys v0.20.0 // indirect
87-
golang.org/x/term v0.20.0 // indirect
85+
golang.org/x/net v0.33.0 // indirect
86+
golang.org/x/oauth2 v0.21.0 // indirect
87+
golang.org/x/sync v0.10.0 // indirect
88+
golang.org/x/sys v0.28.0 // indirect
89+
golang.org/x/term v0.27.0 // indirect
8890
golang.org/x/time v0.5.0 // indirect
89-
golang.org/x/tools v0.21.0 // indirect
91+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
9092
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
91-
google.golang.org/appengine v1.6.7 // indirect
92-
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
93-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
94-
google.golang.org/grpc v1.59.0 // indirect
93+
google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect
94+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
95+
google.golang.org/grpc v1.62.2 // indirect
9596
google.golang.org/protobuf v1.34.2 // indirect
9697
gopkg.in/inf.v0 v0.9.1 // indirect
9798
gopkg.in/yaml.v2 v2.4.0 // indirect
98-
k8s.io/apiextensions-apiserver v0.29.3 // indirect
99-
k8s.io/apiserver v0.29.3 // indirect
100-
k8s.io/cluster-bootstrap v0.29.3 // indirect
101-
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
102-
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect
99+
k8s.io/apiextensions-apiserver v0.30.3 // indirect
100+
k8s.io/apiserver v0.30.3 // indirect
101+
k8s.io/cluster-bootstrap v0.30.3 // indirect
102+
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
103+
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.0 // indirect
103104
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
104105
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
105106
sigs.k8s.io/yaml v1.4.0 // indirect

0 commit comments

Comments
 (0)