Skip to content

Commit 37348bf

Browse files
committed
Upgrade CAPI to 1.7
1 parent 49eea04 commit 37348bf

23 files changed

+390
-765
lines changed

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.6.8 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
247+
git clone --branch v1.7.9 --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

api/v1beta2/cloudstackmachine_types_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package v1beta2_test
1818

1919
import (
20-
"k8s.io/utils/pointer"
20+
"k8s.io/utils/ptr"
2121
capcv1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
2222

2323
"github.com/onsi/ginkgo/v2"
@@ -43,7 +43,7 @@ var _ = ginkgo.Describe("CloudStackMachineConfig_CompressUserdata", func() {
4343
Name: "is false when uncompressed user data is true",
4444
Machine: capcv1.CloudStackMachine{
4545
Spec: capcv1.CloudStackMachineSpec{
46-
UncompressedUserData: pointer.Bool(true),
46+
UncompressedUserData: ptr.To(true),
4747
},
4848
},
4949
Expect: false,
@@ -52,7 +52,7 @@ var _ = ginkgo.Describe("CloudStackMachineConfig_CompressUserdata", func() {
5252
Name: "Is false when uncompressed user data is false",
5353
Machine: capcv1.CloudStackMachine{
5454
Spec: capcv1.CloudStackMachineSpec{
55-
UncompressedUserData: pointer.Bool(false),
55+
UncompressedUserData: ptr.To(false),
5656
},
5757
},
5858
Expect: true,

config/manager/manager.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ spec:
2424
- /manager
2525
args:
2626
- "--leader-elect"
27-
- "--metrics-bind-addr=localhost:8080"
27+
- "--diagnostics-address=${CAPI_DIAGNOSTICS_ADDRESS:=:8443}"
28+
- "--insecure-diagnostics=${CAPI_INSECURE_DIAGNOSTICS:=false}"
2829
- "--cloudstackcluster-concurrency=${CAPC_CLOUDSTACKCLUSTER_CONCURRENCY:=10}"
2930
- "--cloudstackmachine-concurrency=${CAPC_CLOUDSTACKMACHINE_CONCURRENCY:=10}"
3031
- "--enable-cloudstack-cks-sync=${CAPC_CLOUDSTACKMACHINE_CKS_SYNC:=false}"

controllers/cks_machine_controller_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import (
2121
ginkgo "github.com/onsi/ginkgo/v2"
2222
gomega "github.com/onsi/gomega"
2323
"k8s.io/apimachinery/pkg/api/errors"
24-
"k8s.io/utils/pointer"
24+
"k8s.io/utils/ptr"
25+
2526
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
2627
"sigs.k8s.io/cluster-api-provider-cloudstack/controllers"
2728
dummies "sigs.k8s.io/cluster-api-provider-cloudstack/test/dummies/v1beta3"
@@ -34,7 +35,7 @@ var _ = ginkgo.Describe("CksCloudStackMachineReconciler", func() {
3435
ginkgo.Context("With machine controller running.", func() {
3536
ginkgo.BeforeEach(func() {
3637
dummies.SetDummyVars()
37-
dummies.CSCluster.Spec.SyncWithACS = pointer.Bool(true)
38+
dummies.CSCluster.Spec.SyncWithACS = ptr.To(true)
3839
dummies.CSCluster.Spec.FailureDomains = dummies.CSCluster.Spec.FailureDomains[:1]
3940
dummies.CSCluster.Spec.FailureDomains[0].Name = dummies.CSFailureDomain1.Spec.Name
4041
dummies.CSCluster.Status.CloudStackClusterID = "cluster-id-123"

controllers/cloudstackfailuredomain_controller_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
ginkgo "github.com/onsi/ginkgo/v2"
2222
gomega "github.com/onsi/gomega"
2323
"k8s.io/apimachinery/pkg/api/errors"
24-
"k8s.io/utils/pointer"
24+
"k8s.io/utils/ptr"
2525
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
2626
"sigs.k8s.io/cluster-api-provider-cloudstack/pkg/cloud"
2727
dummies "sigs.k8s.io/cluster-api-provider-cloudstack/test/dummies/v1beta3"
@@ -117,17 +117,17 @@ var _ = ginkgo.Describe("CloudStackFailureDomainReconciler", func() {
117117

118118
},
119119
// should delete - simulate owner is kubeadmcontrolplane
120-
ginkgo.Entry("Should delete machine if spec.replicas > 1", true, pointer.Int32(2), pointer.Int32(2), pointer.Int32(2), pointer.Bool(true), true),
120+
ginkgo.Entry("Should delete machine if spec.replicas > 1", true, ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(true), true),
121121
// should delete - simulate owner is etcdadmcluster
122-
ginkgo.Entry("Should delete machine if status.readyReplica does not exist", true, pointer.Int32(2), pointer.Int32(2), nil, pointer.Bool(true), true),
122+
ginkgo.Entry("Should delete machine if status.readyReplica does not exist", true, ptr.To(int32(2)), ptr.To(int32(2)), nil, ptr.To(true), true),
123123
// should delete - simulate owner is machineset
124-
ginkgo.Entry("Should delete machine if status.ready does not exist", true, pointer.Int32(2), pointer.Int32(2), pointer.Int32(2), nil, true),
124+
ginkgo.Entry("Should delete machine if status.ready does not exist", true, ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(int32(2)), nil, true),
125125
// should not delete if condition not met
126-
ginkgo.Entry("Should not delete machine if cluster control plane not ready", false, pointer.Int32(2), pointer.Int32(2), pointer.Int32(2), pointer.Bool(true), false),
127-
ginkgo.Entry("Should not delete machine if status.replicas < spec.replicas", false, pointer.Int32(2), pointer.Int32(1), pointer.Int32(1), pointer.Bool(true), true),
128-
ginkgo.Entry("Should not delete machine if spec.replicas < 2", false, pointer.Int32(1), pointer.Int32(1), pointer.Int32(1), pointer.Bool(true), true),
129-
ginkgo.Entry("Should not delete machine if status.ready is false", false, pointer.Int32(2), pointer.Int32(2), pointer.Int32(2), pointer.Bool(false), true),
130-
ginkgo.Entry("Should not delete machine if status.readyReplicas <> status.replicas", false, pointer.Int32(2), pointer.Int32(2), pointer.Int32(1), pointer.Bool(true), true),
126+
ginkgo.Entry("Should not delete machine if cluster control plane not ready", false, ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(true), false),
127+
ginkgo.Entry("Should not delete machine if status.replicas < spec.replicas", false, ptr.To(int32(2)), ptr.To(int32(1)), ptr.To(int32(1)), ptr.To(true), true),
128+
ginkgo.Entry("Should not delete machine if spec.replicas < 2", false, ptr.To(int32(1)), ptr.To(int32(1)), ptr.To(int32(1)), ptr.To(true), true),
129+
ginkgo.Entry("Should not delete machine if status.ready is false", false, ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(false), true),
130+
ginkgo.Entry("Should not delete machine if status.readyReplicas <> status.replicas", false, ptr.To(int32(2)), ptr.To(int32(2)), ptr.To(int32(1)), ptr.To(true), true),
131131
)
132132
})
133133
})

controllers/cloudstackmachine_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ import (
2424
"regexp"
2525
"time"
2626

27-
"k8s.io/utils/pointer"
28-
2927
"github.com/pkg/errors"
3028
corev1 "k8s.io/api/core/v1"
3129
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3230
"k8s.io/apimachinery/pkg/types"
31+
"k8s.io/utils/ptr"
3332
"sigs.k8s.io/cluster-api/util"
3433
"sigs.k8s.io/cluster-api/util/predicates"
3534
ctrl "sigs.k8s.io/controller-runtime"
@@ -331,8 +330,8 @@ func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.R
331330
// ResolveVMInstanceDetails can get InstanceID by CS machine name
332331
err := r.CSClient.ResolveVMInstanceDetails(r.ReconciliationSubject)
333332
if err != nil {
334-
r.ReconciliationSubject.Status.Status = pointer.String(metav1.StatusFailure)
335-
r.ReconciliationSubject.Status.Reason = pointer.String(err.Error() +
333+
r.ReconciliationSubject.Status.Status = ptr.To(metav1.StatusFailure)
334+
r.ReconciliationSubject.Status.Reason = ptr.To(err.Error() +
336335
fmt.Sprintf(" If this VM has already been deleted, please remove the finalizer named %s from object %s",
337336
"cloudstackmachine.infrastructure.cluster.x-k8s.io", r.ReconciliationSubject.Name))
338337
// Cloudstack VM may be not found or more than one found by name

controllers/cloudstackmachine_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"k8s.io/apimachinery/pkg/api/errors"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
"k8s.io/apimachinery/pkg/types"
29-
"k8s.io/utils/pointer"
29+
"k8s.io/utils/ptr"
3030
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
3131
dummies "sigs.k8s.io/cluster-api-provider-cloudstack/test/dummies/v1beta3"
3232
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
@@ -121,7 +121,7 @@ var _ = ginkgo.Describe("CloudStackMachineReconciler", func() {
121121
})
122122

123123
ginkgo.It("Should call ResolveVMInstanceDetails when CS machine without instanceID deleted", func() {
124-
instanceID := pointer.String("instance-id-123")
124+
instanceID := ptr.To("instance-id-123")
125125
// Mock a call to GetOrCreateVMInstance and set the machine to running.
126126
mockCloudClient.EXPECT().GetOrCreateVMInstance(
127127
gomock.Any(), gomock.Any(), gomock.Any(),

controllers/controllers_suite_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434

3535
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3636
"k8s.io/klog/v2"
37-
"k8s.io/klog/v2/klogr"
3837

3938
"github.com/apache/cloudstack-go/v2/cloudstack"
4039
"github.com/go-logr/logr"
@@ -158,7 +157,7 @@ var _ = ginkgo.BeforeSuite(func() {
158157
gomega.Ω(flag.Lookup("v").Value.Set("1")).Should(gomega.Succeed())
159158
flag.Parse()
160159

161-
logger = klogr.New()
160+
logger = klog.Background()
162161
})
163162

164163
// A mock fo the CloudClient interface used in controller utils.

controllers/utils/base_reconciler_test.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121

2222
"github.com/go-logr/logr"
2323
"github.com/golang/mock/gomock"
24-
. "github.com/onsi/ginkgo/v2"
25-
. "github.com/onsi/gomega"
24+
"github.com/onsi/ginkgo/v2"
25+
"github.com/onsi/gomega"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/runtime"
2828
"k8s.io/client-go/tools/record"
@@ -46,7 +46,7 @@ func (m *mockConcreteRunner) Reconcile() (ctrl.Result, error) {
4646
return ctrl.Result{}, nil
4747
}
4848

49-
var _ = Describe("ReconciliationRunner", func() {
49+
var _ = ginkgo.Describe("ReconciliationRunner", func() {
5050
var (
5151
mockCtrl *gomock.Controller
5252
k8sClient client.Client
@@ -56,11 +56,11 @@ var _ = Describe("ReconciliationRunner", func() {
5656
mockRunner *mockConcreteRunner
5757
)
5858

59-
BeforeEach(func() {
60-
mockCtrl = gomock.NewController(GinkgoT())
59+
ginkgo.BeforeEach(func() {
60+
mockCtrl = gomock.NewController(ginkgo.GinkgoT())
6161
scheme = runtime.NewScheme()
62-
Expect(infrav1.AddToScheme(scheme)).To(Succeed())
63-
Expect(clusterv1.AddToScheme(scheme)).To(Succeed())
62+
gomega.Expect(infrav1.AddToScheme(scheme)).To(gomega.Succeed())
63+
gomega.Expect(clusterv1.AddToScheme(scheme)).To(gomega.Succeed())
6464

6565
k8sClient = fake.NewClientBuilder().WithScheme(scheme).Build()
6666
ctx = context.Background()
@@ -88,16 +88,16 @@ var _ = Describe("ReconciliationRunner", func() {
8888
})
8989
})
9090

91-
AfterEach(func() {
91+
ginkgo.AfterEach(func() {
9292
mockCtrl.Finish()
9393
})
9494

95-
Describe("GetParent", func() {
95+
ginkgo.Describe("GetParent", func() {
9696
var (
9797
child *infrav1.CloudStackMachine
9898
)
9999

100-
BeforeEach(func() {
100+
ginkgo.BeforeEach(func() {
101101
dummies.SetDummyVars()
102102

103103
// Set up child object
@@ -109,9 +109,9 @@ var _ = Describe("ReconciliationRunner", func() {
109109
}
110110
})
111111

112-
Context("when parent exists and is correctly referenced", func() {
112+
ginkgo.Context("when parent exists and is correctly referenced", func() {
113113
var parent *clusterv1.Machine
114-
BeforeEach(func() {
114+
ginkgo.BeforeEach(func() {
115115
parent = &clusterv1.Machine{
116116
ObjectMeta: metav1.ObjectMeta{
117117
Name: "test-parent",
@@ -129,27 +129,27 @@ var _ = Describe("ReconciliationRunner", func() {
129129
}
130130

131131
// Create the objects in the fake client
132-
Expect(k8sClient.Create(ctx, parent)).To(Succeed())
133-
Expect(k8sClient.Create(ctx, child)).To(Succeed())
132+
gomega.Expect(k8sClient.Create(ctx, parent)).To(gomega.Succeed())
133+
gomega.Expect(k8sClient.Create(ctx, child)).To(gomega.Succeed())
134134
})
135135

136-
It("should find the parent successfully", func() {
136+
ginkgo.It("should find the parent successfully", func() {
137137
// Create an empty parent object to be filled
138138
parentToFind := &clusterv1.Machine{}
139139

140140
// Call GetParent
141141
result, err := baseRunner.GetParent(child, parentToFind)()
142142

143143
// Check results
144-
Expect(err).NotTo(HaveOccurred())
145-
Expect(result).To(Equal(ctrl.Result{}))
146-
Expect(parentToFind.Name).To(Equal(parent.Name))
147-
Expect(parentToFind.Namespace).To(Equal(parent.Namespace))
144+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
145+
gomega.Expect(result).To(gomega.Equal(ctrl.Result{}))
146+
gomega.Expect(parentToFind.Name).To(gomega.Equal(parent.Name))
147+
gomega.Expect(parentToFind.Namespace).To(gomega.Equal(parent.Namespace))
148148
})
149149
})
150150

151-
Context("when parent doesn't exist", func() {
152-
BeforeEach(func() {
151+
ginkgo.Context("when parent doesn't exist", func() {
152+
ginkgo.BeforeEach(func() {
153153
// Set up owner reference to non-existent parent
154154
child.OwnerReferences = []metav1.OwnerReference{
155155
{
@@ -161,24 +161,24 @@ var _ = Describe("ReconciliationRunner", func() {
161161
}
162162

163163
// Create only the child in the fake client
164-
Expect(k8sClient.Create(ctx, child)).To(Succeed())
164+
gomega.Expect(k8sClient.Create(ctx, child)).To(gomega.Succeed())
165165
})
166166

167-
It("should return an error", func() {
167+
ginkgo.It("should return an error", func() {
168168
// Create an empty parent object to be filled
169169
parentToFind := &clusterv1.Machine{}
170170

171171
// Call GetParent
172172
_, err := baseRunner.GetParent(child, parentToFind)()
173173

174174
// Check results
175-
Expect(err).To(HaveOccurred())
176-
Expect(err.Error()).To(ContainSubstring("not found"))
175+
gomega.Expect(err).To(gomega.HaveOccurred())
176+
gomega.Expect(err.Error()).To(gomega.ContainSubstring("not found"))
177177
})
178178
})
179179

180-
Context("when no owner reference of requested kind exists", func() {
181-
BeforeEach(func() {
180+
ginkgo.Context("when no owner reference of requested kind exists", func() {
181+
ginkgo.BeforeEach(func() {
182182
// Set up owner reference to different kind
183183
child.OwnerReferences = []metav1.OwnerReference{
184184
{
@@ -190,19 +190,19 @@ var _ = Describe("ReconciliationRunner", func() {
190190
}
191191

192192
// Create only the child in the fake client
193-
Expect(k8sClient.Create(ctx, child)).To(Succeed())
193+
gomega.Expect(k8sClient.Create(ctx, child)).To(gomega.Succeed())
194194
})
195195

196-
It("should requeue with error message", func() {
196+
ginkgo.It("should requeue with error message", func() {
197197
// Create an empty parent object to be filled
198198
parentToFind := &clusterv1.Machine{}
199199

200200
// Call GetParent
201201
result, err := baseRunner.GetParent(child, parentToFind)()
202202

203203
// Check results
204-
Expect(err).NotTo(HaveOccurred())
205-
Expect(result.RequeueAfter).To(Equal(utils.RequeueTimeout))
204+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
205+
gomega.Expect(result.RequeueAfter).To(gomega.Equal(utils.RequeueTimeout))
206206
})
207207
})
208208
})

controllers/utils/utils_suite_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ package utils_test
1919
import (
2020
"testing"
2121

22-
. "github.com/onsi/ginkgo/v2"
23-
. "github.com/onsi/gomega"
22+
"github.com/onsi/ginkgo/v2"
23+
"github.com/onsi/gomega"
2424
)
2525

2626
func TestUtils(t *testing.T) {
27-
RegisterFailHandler(Fail)
28-
RunSpecs(t, "Utils Suite")
27+
gomega.RegisterFailHandler(ginkgo.Fail)
28+
ginkgo.RunSpecs(t, "Utils Suite")
2929
}

0 commit comments

Comments
 (0)