Skip to content

Commit 4de895c

Browse files
authored
Merge pull request #3526 from fabriziopandini/bump-capi-with-ref-changes
🌱 Bump to CAPI 1.11 version with ref changes
2 parents 627ab12 + 8f6e6c6 commit 4de895c

30 files changed

+190
-186
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ IMPORT_BOSS_VER := v0.28.1
190190
IMPORT_BOSS := $(abspath $(TOOLS_BIN_DIR)/$(IMPORT_BOSS_BIN))
191191
IMPORT_BOSS_PKG := k8s.io/code-generator/cmd/import-boss
192192

193-
CAPI_HACK_TOOLS_VER := abcc6d85c72aeaa652976f7f7bb341f0db9f4073 # Note: this the commit ID for CAPI v1.11.0-alpha.1
193+
CAPI_HACK_TOOLS_VER := 4852b676b3ff1adfcd9aa946d4bba883f0339a00 # Note: this the commit ID for CAPI v1.11.0-alpha.1.0.20250624163428-4852b676b3ff
194194

195195
BOSKOSCTL_BIN := boskosctl
196196
BOSKOSCTL := $(abspath $(TOOLS_BIN_DIR)/$(BOSKOSCTL_BIN))

controllers/vmware/servicediscovery_controller_intg_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ var _ = Describe("Service Discovery controller integration tests", func() {
112112
})
113113
Context("When headless svc and endpoints already exists", func() {
114114
BeforeEach(func() {
115-
// Create the svc & endpoint objects in guest cluster
116-
// NOTE: the service account controller is not creating this service because it gets re-queued for 2 minutes
117-
// after being created - when the cluster cache client is not ready.
118-
createObjects(ctx, intCtx.GuestClient, newTestHeadlessSvcEndpoints())
115+
// Wait for the reconciler to create the service.
116+
Eventually(func() error {
117+
key := client.ObjectKey{Namespace: supervisorHeadlessSvcNamespace, Name: supervisorHeadlessSvcName}
118+
return intCtx.GuestAPIReader.Get(ctx, key, &corev1.Service{})
119+
}).Should(Succeed())
119120

120121
// Init objects in the supervisor cluster
121122
initObjects = []client.Object{

controllers/vmware/test/controllers_test.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"k8s.io/klog/v2"
3636
"k8s.io/utils/ptr"
3737
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
38+
"sigs.k8s.io/cluster-api/util"
3839
"sigs.k8s.io/controller-runtime/pkg/cache"
3940
"sigs.k8s.io/controller-runtime/pkg/client"
4041
"sigs.k8s.io/controller-runtime/pkg/config"
@@ -165,11 +166,12 @@ func deployCluster(namespace string, k8sClient client.Client) (client.ObjectKey,
165166
func deployCAPIMachine(namespace string, cluster *clusterv1.Cluster, k8sClient client.Client) (client.ObjectKey, *clusterv1.Machine) {
166167
// A finalizer is added to prevent it from being deleted until its
167168
// dependents are removed.
169+
name := "test-" + util.RandomString(5)
168170
machine := &clusterv1.Machine{
169171
ObjectMeta: metav1.ObjectMeta{
170-
GenerateName: "test-",
171-
Namespace: namespace,
172-
Finalizers: []string{"test"},
172+
Name: name,
173+
Namespace: namespace,
174+
Finalizers: []string{"test"},
173175
Labels: map[string]string{
174176
clusterv1.ClusterNameLabel: cluster.Name,
175177
clusterv1.MachineControlPlaneLabel: "",
@@ -185,6 +187,11 @@ func deployCAPIMachine(namespace string, cluster *clusterv1.Cluster, k8sClient c
185187
},
186188
Spec: clusterv1.MachineSpec{
187189
ClusterName: cluster.Name,
190+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
191+
Kind: "VSphereMachine",
192+
Name: name, // We know that the infra machine is going to be called like the machine.
193+
APIGroup: vmwarev1.GroupVersion.Group,
194+
},
188195
},
189196
}
190197
Expect(k8sClient.Create(ctx, machine)).To(Succeed())
@@ -213,10 +220,10 @@ func deployInfraMachine(namespace string, machine *clusterv1.Machine, finalizers
213220
// Updates the InfrastructureRef of a CAPI Cluster to a VSphereCluster. Function
214221
// does not block on update success.
215222
func updateClusterInfraRef(cluster *clusterv1.Cluster, infraCluster client.Object, k8sClient client.Client) {
216-
cluster.Spec.InfrastructureRef = &corev1.ObjectReference{
217-
APIVersion: infraCluster.GetObjectKind().GroupVersionKind().GroupVersion().String(),
218-
Kind: infraCluster.GetObjectKind().GroupVersionKind().Kind,
219-
Name: infraCluster.GetName(),
223+
cluster.Spec.InfrastructureRef = &clusterv1.ContractVersionedObjectReference{
224+
APIGroup: vmwarev1.GroupVersion.Group,
225+
Kind: "VSphereCluster",
226+
Name: infraCluster.GetName(),
220227
}
221228
Expect(k8sClient.Update(ctx, cluster)).To(Succeed())
222229
}
@@ -551,14 +558,20 @@ var _ = Describe("Reconciliation tests", func() {
551558
By("Create the CAPI Machine and wait for it to exist")
552559
// A finalizer is added to prevent it from being deleted until its
553560
// dependents are removed.
561+
name := "test-" + util.RandomString(5)
554562
machine := &clusterv1.Machine{
555563
ObjectMeta: metav1.ObjectMeta{
556-
GenerateName: "test-",
557-
Namespace: ns.Name,
558-
Finalizers: []string{"test"},
564+
Name: name,
565+
Namespace: ns.Name,
566+
Finalizers: []string{"test"},
559567
},
560568
Spec: clusterv1.MachineSpec{
561569
ClusterName: "crud",
570+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
571+
Kind: "VSphereMachine",
572+
Name: name, // We know that the infra machine is going to be called like the machine.
573+
APIGroup: vmwarev1.GroupVersion.Group,
574+
},
562575
},
563576
}
564577
Expect(k8sClient.Create(ctx, machine)).To(Succeed())

controllers/vspherecluster_reconciler_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
104104
Namespace: "default",
105105
},
106106
Spec: clusterv1.ClusterSpec{
107-
InfrastructureRef: &corev1.ObjectReference{
108-
APIVersion: infrav1.GroupVersion.String(),
109-
Kind: "VsphereCluster",
110-
Name: instance.Name,
107+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
108+
APIGroup: infrav1.GroupVersion.Group,
109+
Kind: "VsphereCluster",
110+
Name: instance.Name,
111111
},
112112
},
113113
}
@@ -173,10 +173,10 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
173173
Namespace: "default",
174174
},
175175
Spec: clusterv1.ClusterSpec{
176-
InfrastructureRef: &corev1.ObjectReference{
177-
APIVersion: infrav1.GroupVersion.String(),
178-
Kind: "VsphereCluster",
179-
Name: "vsphere-test1",
176+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
177+
APIGroup: infrav1.GroupVersion.Group,
178+
Kind: "VsphereCluster",
179+
Name: "vsphere-test1",
180180
},
181181
},
182182
}
@@ -257,10 +257,10 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
257257
Namespace: "default",
258258
},
259259
Spec: clusterv1.ClusterSpec{
260-
InfrastructureRef: &corev1.ObjectReference{
261-
APIVersion: infrav1.GroupVersion.String(),
262-
Kind: "VsphereCluster",
263-
Name: "vsphere-test1",
260+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
261+
APIGroup: infrav1.GroupVersion.Group,
262+
Kind: "VsphereCluster",
263+
Name: "vsphere-test1",
264264
},
265265
},
266266
}
@@ -365,10 +365,10 @@ var _ = Describe("VIM based VSphere ClusterReconciler", func() {
365365
Namespace: namespace.Name,
366366
},
367367
Spec: clusterv1.ClusterSpec{
368-
InfrastructureRef: &corev1.ObjectReference{
369-
APIVersion: infrav1.GroupVersion.String(),
370-
Kind: "VSphereCluster",
371-
Name: "vsphere-test2",
368+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
369+
APIGroup: infrav1.GroupVersion.Group,
370+
Kind: "VSphereCluster",
371+
Name: "vsphere-test2",
372372
},
373373
},
374374
}

controllers/vspheredeploymentzone_controller_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,16 @@ func createMachine(machineName, clusterName, namespace string, isControlPlane bo
547547
Spec: clusterv1.MachineSpec{
548548
Version: ptr.To("v1.22.0"),
549549
Bootstrap: clusterv1.Bootstrap{
550-
ConfigRef: &corev1.ObjectReference{
551-
APIVersion: bootstrapv1.GroupVersion.String(),
552-
Name: machineName,
550+
ConfigRef: &clusterv1.ContractVersionedObjectReference{
551+
APIGroup: bootstrapv1.GroupVersion.Group,
552+
Kind: "KubeadmConfig",
553+
Name: machineName,
553554
},
554555
},
555-
InfrastructureRef: corev1.ObjectReference{
556-
APIVersion: infrav1.GroupVersion.String(),
557-
Kind: "VSphereMachine",
558-
Name: machineName,
556+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
557+
APIGroup: infrav1.GroupVersion.Group,
558+
Kind: "VSphereMachine",
559+
Name: machineName,
559560
},
560561
ClusterName: clusterName,
561562
},

controllers/vspheremachine_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,16 @@ func (r *machineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_
323323
// version of CAPV to prevent VSphereMachines from being orphaned, but is no longer needed.
324324
// For more info see: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/issues/2054
325325
// TODO: This should be removed in a future release of CAPV.
326+
apiVersion := infrav1.GroupVersion.String()
327+
if r.supervisorBased {
328+
apiVersion = vmwarev1.GroupVersion.String()
329+
}
326330
machineContext.GetVSphereMachine().SetOwnerReferences(
327331
clusterutilv1.RemoveOwnerRef(
328332
machineContext.GetVSphereMachine().GetOwnerReferences(),
329333
metav1.OwnerReference{
330334
Name: cluster.Spec.InfrastructureRef.Name,
331-
APIVersion: cluster.Spec.InfrastructureRef.APIVersion,
335+
APIVersion: apiVersion,
332336
Kind: cluster.Spec.InfrastructureRef.Kind,
333337
},
334338
),

controllers/vspheremachine_controller_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ var _ = Describe("VsphereMachineReconciler", func() {
6868
Namespace: testNs.Name,
6969
},
7070
Spec: clusterv1.ClusterSpec{
71-
InfrastructureRef: &corev1.ObjectReference{
72-
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
73-
Kind: "VSphereCluster",
74-
Name: "vsphere-test1",
71+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
72+
APIGroup: "infrastructure.cluster.x-k8s.io",
73+
Kind: "VSphereCluster",
74+
Name: "vsphere-test1",
7575
},
7676
},
7777
}
@@ -105,10 +105,10 @@ var _ = Describe("VsphereMachineReconciler", func() {
105105
},
106106
Spec: clusterv1.MachineSpec{
107107
ClusterName: capiCluster.Name,
108-
InfrastructureRef: corev1.ObjectReference{
109-
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
110-
Kind: "VSphereMachine",
111-
Name: "vsphere-machine-1",
108+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
109+
APIGroup: "infrastructure.cluster.x-k8s.io",
110+
Kind: "VSphereMachine",
111+
Name: "vsphere-machine-1",
112112
},
113113
},
114114
}
@@ -237,10 +237,10 @@ func Test_machineReconciler_Metadata(t *testing.T) {
237237
Namespace: ns.Name,
238238
},
239239
Spec: clusterv1.ClusterSpec{
240-
InfrastructureRef: &corev1.ObjectReference{
241-
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
242-
Kind: "VSphereCluster",
243-
Name: "vsphere-test1",
240+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
241+
APIGroup: "infrastructure.cluster.x-k8s.io",
242+
Kind: "VSphereCluster",
243+
Name: "vsphere-test1",
244244
},
245245
},
246246
}
@@ -280,10 +280,10 @@ func Test_machineReconciler_Metadata(t *testing.T) {
280280
},
281281
Spec: clusterv1.MachineSpec{
282282
ClusterName: capiCluster.Name,
283-
InfrastructureRef: corev1.ObjectReference{
284-
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
285-
Kind: "VSphereMachine",
286-
Name: "vsphere-machine-1",
283+
InfrastructureRef: clusterv1.ContractVersionedObjectReference{
284+
APIGroup: "infrastructure.cluster.x-k8s.io",
285+
Kind: "VSphereMachine",
286+
Name: "vsphere-machine-1",
287287
},
288288
},
289289
}

controllers/vspherevm_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestReconcileNormal_WaitingForIPAddrAllocation(t *testing.T) {
8787
Namespace: "test",
8888
},
8989
Spec: clusterv1.ClusterSpec{
90-
InfrastructureRef: &corev1.ObjectReference{
90+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
9191
Name: vsphereCluster.Name,
9292
},
9393
},
@@ -475,7 +475,7 @@ func TestRetrievingVCenterCredentialsFromCluster(t *testing.T) {
475475
Namespace: "test",
476476
},
477477
Spec: clusterv1.ClusterSpec{
478-
InfrastructureRef: &corev1.ObjectReference{
478+
InfrastructureRef: &clusterv1.ContractVersionedObjectReference{
479479
Name: vsphereCluster.Name,
480480
},
481481
},

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module sigs.k8s.io/cluster-api-provider-vsphere
22

33
go 1.24.0
44

5-
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.11.0-alpha.1
5+
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.11.0-alpha.1.0.20250624163428-4852b676b3ff
66

77
replace github.com/vmware-tanzu/vm-operator/pkg/constants/testlabels => github.com/vmware-tanzu/vm-operator/pkg/constants/testlabels v0.0.0-20240404200847-de75746a9505
88

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6J
376376
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
377377
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM=
378378
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
379-
sigs.k8s.io/cluster-api v1.11.0-alpha.1 h1:8apMLTVE7NC+vLM8Xi5TVk0OoEHW8DT8L09IoBOBlgs=
380-
sigs.k8s.io/cluster-api v1.11.0-alpha.1/go.mod h1:5CVeCZAsEBg/eZpr7wsYntHE7QFqMX8IzNH+MWhAhQg=
379+
sigs.k8s.io/cluster-api v1.11.0-alpha.1.0.20250624163428-4852b676b3ff h1:P3MCrNBqRkeUP88ltOt0+FhmyJtCrNfYgsAiqrvmHV4=
380+
sigs.k8s.io/cluster-api v1.11.0-alpha.1.0.20250624163428-4852b676b3ff/go.mod h1:ZSXsSe4gbkdXb93KlA94JRl7YmSniekbhePSIWSIUiY=
381381
sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8=
382382
sigs.k8s.io/controller-runtime v0.21.0/go.mod h1:OSg14+F65eWqIu4DceX7k/+QRAbTTvxeQSNSOQpukWM=
383383
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=

0 commit comments

Comments
 (0)