Skip to content

Commit c5028c3

Browse files
committed
e2e: migrate to use v1beta2 to fulfill CAPI framework function signatures
1 parent 0a8f0cf commit c5028c3

30 files changed

+223
-177
lines changed

api/v1beta1/azuremachinetemplate_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (r *azureMachineTemplateWebhook) ValidateUpdate(ctx context.Context, oldRaw
111111
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a admission.Request inside context: %v", err))
112112
}
113113

114-
if !topology.ShouldSkipImmutabilityChecks(req, t) &&
114+
if !topology.IsDryRunRequest(req, t) &&
115115
!reflect.DeepEqual(t.Spec.Template.Spec, old.Spec.Template.Spec) {
116116
// The equality failure could be because of default mismatch between v1alpha3 and v1beta1. This happens because
117117
// the new object `r` will have run through the default webhooks but the old object `old` would not have so.

controllers/azureasomanagedcontrolplane_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) {
465465
}
466466
result, err := r.Reconcile(ctx, ctrl.Request{NamespacedName: client.ObjectKeyFromObject(asoManagedControlPlane)})
467467
g.Expect(err).NotTo(HaveOccurred())
468-
g.Expect(result.Requeue).To(BeFalse())
468+
g.Expect(result.Requeue).To(BeFalse()) //nolint:staticcheck
469469
g.Expect(result.RequeueAfter).NotTo(BeZero())
470470

471471
g.Expect(c.Get(ctx, client.ObjectKeyFromObject(asoManagedControlPlane), asoManagedControlPlane)).To(Succeed())

exp/api/v1beta1/azuremachinepool_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (amp *AzureMachinePool) SetIdentityDefaults(client client.Client) error {
7070
return nil
7171
}
7272
if amp.Spec.Identity == infrav1.VMIdentitySystemAssigned {
73-
machinePool, err := azureutil.FindParentMachinePoolWithRetry(amp.Name, client, 5)
73+
machinePool, err := azureutil.FindParentMachinePoolWithRetryV1Beta1(amp.Name, client, 5)
7474
if err != nil {
7575
return errors.Wrap(err, "failed to find parent machine pool")
7676
}

exp/api/v1beta1/azuremachinepool_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (amp *AzureMachinePool) ValidateOrchestrationMode(c client.Client) func() e
299299
return func() error {
300300
// Only Flexible orchestration mode requires validation.
301301
if amp.Spec.OrchestrationMode == infrav1.OrchestrationModeType(armcompute.OrchestrationModeFlexible) {
302-
parent, err := azureutil.FindParentMachinePoolWithRetry(amp.Name, c, 5)
302+
parent, err := azureutil.FindParentMachinePoolWithRetryV1Beta1(amp.Name, c, 5)
303303
if err != nil {
304304
return errors.Wrap(err, "failed to find parent MachinePool")
305305
}

test/e2e/aks.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2929
"k8s.io/apimachinery/pkg/types"
3030
"k8s.io/utils/ptr"
31-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
31+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3232
"sigs.k8s.io/cluster-api/test/framework"
3333
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3434
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -40,7 +40,7 @@ import (
4040
type DiscoverAndWaitForAKSControlPlaneInput struct {
4141
Lister framework.Lister
4242
Getter framework.Getter
43-
Cluster *clusterv1beta1.Cluster
43+
Cluster *clusterv1.Cluster
4444
}
4545

4646
// WaitForAKSControlPlaneInitialized waits for the Azure managed control plane to be initialized.
@@ -72,7 +72,7 @@ func DiscoverAndWaitForAKSControlPlaneInitialized(ctx context.Context, input Dis
7272
Expect(input.Lister).NotTo(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoverAndWaitForAKSControlPlaneInitialized")
7373
Expect(input.Cluster).NotTo(BeNil(), "Invalid argument. input.Cluster can't be nil when calling DiscoverAndWaitForAKSControlPlaneInitialized")
7474

75-
controlPlaneNamespace := input.Cluster.Spec.ControlPlaneRef.Namespace
75+
controlPlaneNamespace := input.Cluster.Namespace
7676
controlPlaneName := input.Cluster.Spec.ControlPlaneRef.Name
7777

7878
Logf("Waiting for the first AKS machine in the %s/%s 'system' node pool to exist", controlPlaneNamespace, controlPlaneName)
@@ -91,7 +91,7 @@ func DiscoverAndWaitForAKSControlPlaneReady(ctx context.Context, input DiscoverA
9191
Expect(input.Lister).NotTo(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoverAndWaitForAKSControlPlaneReady")
9292
Expect(input.Cluster).NotTo(BeNil(), "Invalid argument. input.Cluster can't be nil when calling DiscoverAndWaitForAKSControlPlaneReady")
9393

94-
controlPlaneNamespace := input.Cluster.Spec.ControlPlaneRef.Namespace
94+
controlPlaneNamespace := input.Cluster.Namespace
9595
controlPlaneName := input.Cluster.Spec.ControlPlaneRef.Name
9696

9797
Logf("Waiting for all AKS machines in the %s/%s 'system' node pool to exist", controlPlaneNamespace, controlPlaneName)
@@ -132,7 +132,7 @@ const (
132132
)
133133

134134
// value returns the integer equivalent of controlPlaneReplicas
135-
func (r controlPlaneReplicas) value(mp *clusterv1beta1.MachinePool) int {
135+
func (r controlPlaneReplicas) value(mp *clusterv1.MachinePool) int {
136136
switch r {
137137
case atLeastOne:
138138
return 1
@@ -147,7 +147,7 @@ func WaitForAKSSystemNodePoolMachinesToExist(ctx context.Context, input WaitForC
147147
Eventually(func() bool {
148148
opt1 := client.InNamespace(input.Namespace)
149149
opt2 := client.MatchingLabels(map[string]string{
150-
clusterv1beta1.ClusterNameLabel: input.ClusterName,
150+
clusterv1.ClusterNameLabel: input.ClusterName,
151151
})
152152
opt3 := client.MatchingLabels(map[string]string{
153153
infrav1.LabelAgentPoolMode: string(infrav1.NodePoolModeSystem),
@@ -201,7 +201,7 @@ func WaitForAKSSystemNodePoolMachinesToExist(ctx context.Context, input WaitForC
201201
continue
202202
}
203203

204-
ownerMachinePool := &clusterv1beta1.MachinePool{}
204+
ownerMachinePool := &clusterv1.MachinePool{}
205205
if err := input.Getter.Get(ctx, types.NamespacedName{Namespace: input.Namespace, Name: ref.Name},
206206
ownerMachinePool); err != nil {
207207
LogWarningf("Failed to get machinePool: %+v", err)

test/e2e/aks_adopt.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import (
2525
. "github.com/onsi/gomega"
2626
apierrors "k8s.io/apimachinery/pkg/api/errors"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
28+
"k8s.io/utils/ptr"
29+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
2930
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3031
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3132
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -36,8 +37,8 @@ import (
3637
type AKSAdoptSpecInput struct {
3738
ApplyInput clusterctl.ApplyClusterTemplateAndWaitInput
3839
ApplyResult *clusterctl.ApplyClusterTemplateAndWaitResult
39-
Cluster *clusterv1beta1.Cluster
40-
MachinePools []*clusterv1beta1.MachinePool
40+
Cluster *clusterv1.Cluster
41+
MachinePools []*clusterv1.MachinePool
4142
}
4243

4344
// AKSAdoptSpec tests adopting an existing AKS cluster into management by CAPZ. It first relies on a CAPZ AKS
@@ -92,22 +93,22 @@ func AKSAdoptSpec(ctx context.Context, inputGetter func() AKSAdoptSpecInput) {
9293
cluster := input.Cluster
9394
Eventually(func(g Gomega) {
9495
g.Expect(mgmtClient.Get(ctx, client.ObjectKeyFromObject(cluster), cluster)).To(Succeed())
95-
cluster.Spec.Paused = true
96+
cluster.Spec.Paused = ptr.To(true)
9697
g.Expect(mgmtClient.Update(ctx, cluster)).To(Succeed())
9798
}, updateResource...).Should(Succeed())
9899

99100
// wait for the pause to take effect before deleting anything
100101
amcp := &infrav1.AzureManagedControlPlane{
101102
ObjectMeta: metav1.ObjectMeta{
102-
Namespace: cluster.Spec.ControlPlaneRef.Namespace,
103+
Namespace: cluster.Namespace,
103104
Name: cluster.Spec.ControlPlaneRef.Name,
104105
},
105106
}
106107
waitForNoBlockMove(amcp)
107108
for _, mp := range input.MachinePools {
108109
ammp := &infrav1.AzureManagedMachinePool{
109110
ObjectMeta: metav1.ObjectMeta{
110-
Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace,
111+
Namespace: mp.Namespace,
111112
Name: mp.Spec.Template.Spec.InfrastructureRef.Name,
112113
},
113114
}
@@ -121,7 +122,7 @@ func AKSAdoptSpec(ctx context.Context, inputGetter func() AKSAdoptSpecInput) {
121122

122123
ammp := &infrav1.AzureManagedMachinePool{
123124
ObjectMeta: metav1.ObjectMeta{
124-
Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace,
125+
Namespace: mp.Namespace,
125126
Name: mp.Spec.Template.Spec.InfrastructureRef.Name,
126127
},
127128
}
@@ -137,7 +138,7 @@ func AKSAdoptSpec(ctx context.Context, inputGetter func() AKSAdoptSpecInput) {
137138
// AzureManagedCluster never gets a finalizer
138139
deleteAndWait(&infrav1.AzureManagedCluster{
139140
ObjectMeta: metav1.ObjectMeta{
140-
Namespace: cluster.Spec.InfrastructureRef.Namespace,
141+
Namespace: cluster.Namespace,
141142
Name: cluster.Spec.InfrastructureRef.Name,
142143
},
143144
})

test/e2e/aks_autoscaler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ import (
2828
. "github.com/onsi/gomega"
2929
"k8s.io/apimachinery/pkg/types"
3030
"k8s.io/utils/ptr"
31-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
31+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3232
"sigs.k8s.io/controller-runtime/pkg/client"
3333

3434
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
3535
)
3636

3737
type AKSAutoscaleSpecInput struct {
38-
Cluster *clusterv1beta1.Cluster
39-
MachinePool *clusterv1beta1.MachinePool
38+
Cluster *clusterv1.Cluster
39+
MachinePool *clusterv1.MachinePool
4040
WaitIntervals []interface{}
4141
}
4242

@@ -52,7 +52,7 @@ func AKSAutoscaleSpec(ctx context.Context, inputGetter func() AKSAutoscaleSpecIn
5252

5353
amcp := &infrav1.AzureManagedControlPlane{}
5454
err = mgmtClient.Get(ctx, types.NamespacedName{
55-
Namespace: input.Cluster.Spec.ControlPlaneRef.Namespace,
55+
Namespace: input.Cluster.Namespace,
5656
Name: input.Cluster.Spec.ControlPlaneRef.Name,
5757
}, amcp)
5858
Expect(err).NotTo(HaveOccurred())

test/e2e/aks_azure_cluster_autoscaler.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import (
2828
. "github.com/onsi/gomega"
2929
"k8s.io/apimachinery/pkg/types"
3030
"k8s.io/utils/ptr"
31-
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
31+
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3232

3333
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
3434
)
3535

3636
type AKSAzureClusterAutoscalerSettingsSpecInput struct {
37-
Cluster *clusterv1beta1.Cluster
37+
Cluster *clusterv1.Cluster
3838
WaitIntervals []interface{}
3939
}
4040

@@ -54,7 +54,7 @@ func AKSAzureClusterAutoscalerSettingsSpec(ctx context.Context, inputGetter func
5454
amcp := &infrav1.AzureManagedControlPlane{}
5555
Eventually(func(g Gomega) {
5656
err = mgmtClient.Get(ctx, types.NamespacedName{
57-
Namespace: input.Cluster.Spec.ControlPlaneRef.Namespace,
57+
Namespace: input.Cluster.Namespace,
5858
Name: input.Cluster.Spec.ControlPlaneRef.Name,
5959
}, amcp)
6060
g.Expect(err).NotTo(HaveOccurred())
@@ -76,15 +76,15 @@ func AKSAzureClusterAutoscalerSettingsSpec(ctx context.Context, inputGetter func
7676

7777
amcp.Spec.AutoScalerProfile = nil
7878
err = mgmtClient.Get(ctx, types.NamespacedName{
79-
Namespace: input.Cluster.Spec.ControlPlaneRef.Namespace,
79+
Namespace: input.Cluster.Namespace,
8080
Name: input.Cluster.Spec.ControlPlaneRef.Name,
8181
}, amcp)
8282
g.Expect(err).NotTo(HaveOccurred())
8383
g.Expect(mgmtClient.Update(ctx, amcp)).To(Succeed())
8484
}, input.WaitIntervals...).Should(Succeed())
8585
Eventually(func(g Gomega) {
8686
err = mgmtClient.Get(ctx, types.NamespacedName{
87-
Namespace: input.Cluster.Spec.ControlPlaneRef.Namespace,
87+
Namespace: input.Cluster.Namespace,
8888
Name: input.Cluster.Spec.ControlPlaneRef.Name,
8989
}, amcp)
9090
g.Expect(err).NotTo(HaveOccurred())
@@ -94,7 +94,7 @@ func AKSAzureClusterAutoscalerSettingsSpec(ctx context.Context, inputGetter func
9494
// Now set to the new value
9595
Eventually(func(g Gomega) {
9696
err = mgmtClient.Get(ctx, types.NamespacedName{
97-
Namespace: input.Cluster.Spec.ControlPlaneRef.Namespace,
97+
Namespace: input.Cluster.Namespace,
9898
Name: input.Cluster.Spec.ControlPlaneRef.Name,
9999
}, amcp)
100100
g.Expect(err).NotTo(HaveOccurred())
@@ -115,7 +115,7 @@ func AKSAzureClusterAutoscalerSettingsSpec(ctx context.Context, inputGetter func
115115

116116
Eventually(func(g Gomega) {
117117
err = mgmtClient.Get(ctx, types.NamespacedName{
118-
Namespace: input.Cluster.Spec.ControlPlaneRef.Namespace,
118+
Namespace: input.Cluster.Namespace,
119119
Name: input.Cluster.Spec.ControlPlaneRef.Name,
120120
}, amcp)
121121
g.Expect(err).NotTo(HaveOccurred())
@@ -124,7 +124,7 @@ func AKSAzureClusterAutoscalerSettingsSpec(ctx context.Context, inputGetter func
124124
}, input.WaitIntervals...).Should(Succeed())
125125
Eventually(func(g Gomega) {
126126
err = mgmtClient.Get(ctx, types.NamespacedName{
127-
Namespace: input.Cluster.Spec.ControlPlaneRef.Namespace,
127+
Namespace: input.Cluster.Namespace,
128128
Name: input.Cluster.Spec.ControlPlaneRef.Name,
129129
}, amcp)
130130
g.Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)