Skip to content

Commit 4add3e9

Browse files
committed
Refactor AKS machine pool spec to target a specific management cluster
1 parent 73e4394 commit 4add3e9

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
@@ -38,6 +38,7 @@ import (
3838
)
3939

4040
type AKSMachinePoolSpecInput struct {
41+
MgmtCluster framework.ClusterProxy
4142
Cluster *clusterv1.Cluster
4243
MachinePools []*expv1.MachinePool
4344
WaitIntervals []interface{}
@@ -57,7 +58,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
5758

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

6768
Byf("Scaling machine pool %s in", mp.Name)
6869
framework.ScaleMachinePoolAndWait(ctx, framework.ScaleMachinePoolAndWaitInput{
69-
ClusterProxy: bootstrapClusterProxy,
70+
ClusterProxy: input.MgmtCluster,
7071
Cluster: input.Cluster,
7172
Replicas: ptr.Deref(mp.Spec.Replicas, 0) - 1,
7273
MachinePools: []*expv1.MachinePool{mp},
@@ -78,7 +79,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
7879
switch mp.Spec.Template.Spec.InfrastructureRef.Kind {
7980
case infrav1.AzureManagedMachinePoolKind:
8081
ammp := &infrav1.AzureManagedMachinePool{}
81-
err := bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{
82+
err := input.MgmtCluster.GetClient().Get(ctx, types.NamespacedName{
8283
Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace,
8384
Name: mp.Spec.Template.Spec.InfrastructureRef.Name,
8485
}, ammp)
@@ -89,7 +90,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
8990
}
9091
case infrav1.AzureASOManagedMachinePoolKind:
9192
ammp := &infrav1.AzureASOManagedMachinePool{}
92-
err := bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{
93+
err := input.MgmtCluster.GetClient().Get(ctx, types.NamespacedName{
9394
Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace,
9495
Name: mp.Spec.Template.Spec.InfrastructureRef.Name,
9596
}, ammp)
@@ -104,7 +105,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
104105
// mode may not be set in spec. Get the ASO object and check in status.
105106
resource.SetNamespace(ammp.Namespace)
106107
agentPool := &asocontainerservicev1.ManagedClustersAgentPool{}
107-
Expect(bootstrapClusterProxy.GetClient().Get(ctx, client.ObjectKeyFromObject(resource), agentPool)).To(Succeed())
108+
Expect(input.MgmtCluster.GetClient().Get(ctx, client.ObjectKeyFromObject(resource), agentPool)).To(Succeed())
108109
if ptr.Deref(agentPool.Status.Mode, "") != asocontainerservicev1.AgentPoolMode_STATUS_System {
109110
isUserPool = true
110111
}
@@ -115,7 +116,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
115116
if isUserPool {
116117
Byf("Scaling the machine pool %s to zero", mp.Name)
117118
framework.ScaleMachinePoolAndWait(ctx, framework.ScaleMachinePoolAndWaitInput{
118-
ClusterProxy: bootstrapClusterProxy,
119+
ClusterProxy: input.MgmtCluster,
119120
Cluster: input.Cluster,
120121
Replicas: 0,
121122
MachinePools: []*expv1.MachinePool{mp},
@@ -125,7 +126,7 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp
125126

126127
Byf("Restoring initial replica count for machine pool %s", mp.Name)
127128
framework.ScaleMachinePoolAndWait(ctx, framework.ScaleMachinePoolAndWaitInput{
128-
ClusterProxy: bootstrapClusterProxy,
129+
ClusterProxy: input.MgmtCluster,
129130
Cluster: input.Cluster,
130131
Replicas: originalReplicas,
131132
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)