Skip to content

Commit 78fd706

Browse files
committed
Refactor AKS machine pool spec to target a specific management cluster
1 parent 9b1a271 commit 78fd706

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

test/e2e/aks_machinepools.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
)
4040

4141
type AKSMachinePoolSpecInput struct {
42+
MgmtCluster framework.ClusterProxy
4243
Cluster *clusterv1.Cluster
4344
MachinePools []*expv1.MachinePool
4445
WaitIntervals []interface{}
@@ -58,7 +59,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
5859

5960
Byf("Scaling machine pool %s out", mp.Name)
6061
framework.ScaleMachinePoolAndWait(ctx, framework.ScaleMachinePoolAndWaitInput{
61-
ClusterProxy: bootstrapClusterProxy,
62+
ClusterProxy: input.MgmtCluster,
6263
Cluster: input.Cluster,
6364
Replicas: ptr.Deref(mp.Spec.Replicas, 0) + 1,
6465
MachinePools: []*expv1.MachinePool{mp},
@@ -67,7 +68,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
6768

6869
Byf("Scaling machine pool %s in", mp.Name)
6970
framework.ScaleMachinePoolAndWait(ctx, framework.ScaleMachinePoolAndWaitInput{
70-
ClusterProxy: bootstrapClusterProxy,
71+
ClusterProxy: input.MgmtCluster,
7172
Cluster: input.Cluster,
7273
Replicas: ptr.Deref(mp.Spec.Replicas, 0) - 1,
7374
MachinePools: []*expv1.MachinePool{mp},
@@ -79,7 +80,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
7980
switch mp.Spec.Template.Spec.InfrastructureRef.Kind {
8081
case infrav1.AzureManagedMachinePoolKind:
8182
ammp := &infrav1.AzureManagedMachinePool{}
82-
err := bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{
83+
err := input.MgmtCluster.GetClient().Get(ctx, types.NamespacedName{
8384
Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace,
8485
Name: mp.Spec.Template.Spec.InfrastructureRef.Name,
8586
}, ammp)
@@ -90,7 +91,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
9091
}
9192
case infrav1alpha.AzureASOManagedMachinePoolKind:
9293
ammp := &infrav1alpha.AzureASOManagedMachinePool{}
93-
err := bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{
94+
err := input.MgmtCluster.GetClient().Get(ctx, types.NamespacedName{
9495
Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace,
9596
Name: mp.Spec.Template.Spec.InfrastructureRef.Name,
9697
}, ammp)
@@ -105,7 +106,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
105106
// mode may not be set in spec. Get the ASO object and check in status.
106107
resource.SetNamespace(ammp.Namespace)
107108
agentPool := &asocontainerservicev1.ManagedClustersAgentPool{}
108-
Expect(bootstrapClusterProxy.GetClient().Get(ctx, client.ObjectKeyFromObject(resource), agentPool)).To(Succeed())
109+
Expect(input.MgmtCluster.GetClient().Get(ctx, client.ObjectKeyFromObject(resource), agentPool)).To(Succeed())
109110
if ptr.Deref(agentPool.Status.Mode, "") != asocontainerservicev1.AgentPoolMode_STATUS_System {
110111
isUserPool = true
111112
}
@@ -116,7 +117,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
116117
if isUserPool {
117118
Byf("Scaling the machine pool %s to zero", mp.Name)
118119
framework.ScaleMachinePoolAndWait(ctx, framework.ScaleMachinePoolAndWaitInput{
119-
ClusterProxy: bootstrapClusterProxy,
120+
ClusterProxy: input.MgmtCluster,
120121
Cluster: input.Cluster,
121122
Replicas: 0,
122123
MachinePools: []*expv1.MachinePool{mp},
@@ -126,7 +127,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
126127

127128
Byf("Restoring initial replica count for machine pool %s", mp.Name)
128129
framework.ScaleMachinePoolAndWait(ctx, framework.ScaleMachinePoolAndWaitInput{
129-
ClusterProxy: bootstrapClusterProxy,
130+
ClusterProxy: input.MgmtCluster,
130131
Cluster: input.Cluster,
131132
Replicas: originalReplicas,
132133
MachinePools: []*expv1.MachinePool{mp},

test/e2e/azure_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ var _ = Describe("Workload cluster creation", func() {
821821
By("Exercising machine pools", func() {
822822
AKSMachinePoolSpec(ctx, func() AKSMachinePoolSpecInput {
823823
return AKSMachinePoolSpecInput{
824+
MgmtCluster: bootstrapClusterProxy,
824825
Cluster: result.Cluster,
825826
MachinePools: result.MachinePools,
826827
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
@@ -982,6 +983,7 @@ var _ = Describe("Workload cluster creation", func() {
982983
By("Exercising machine pools", func() {
983984
AKSMachinePoolSpec(ctx, func() AKSMachinePoolSpecInput {
984985
return AKSMachinePoolSpecInput{
986+
MgmtCluster: bootstrapClusterProxy,
985987
Cluster: result.Cluster,
986988
MachinePools: result.MachinePools,
987989
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"),

0 commit comments

Comments
 (0)