From b5d161b056bf2c7a2d7602b9fbb3e16ceda69b29 Mon Sep 17 00:00:00 2001 From: willie-yao Date: Wed, 4 Oct 2023 00:15:51 +0000 Subject: [PATCH] Try fix autoscaler test --- config/capz/manager_image_patch.yaml | 2 +- config/capz/manager_pull_policy.yaml | 2 +- ...luster-template-aks-clusterclass-cluster.yaml | 2 +- .../aks-clusterclass-cluster/cluster.yaml | 2 +- .../ci/prow-aks-clusterclass/kustomization.yaml | 1 + .../prow-aks-clusterclass/patches/cluster.yaml | 7 +++++++ test/e2e/aks_autoscaler.go | 16 ++++++++++++---- 7 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 templates/test/ci/prow-aks-clusterclass/patches/cluster.yaml diff --git a/config/capz/manager_image_patch.yaml b/config/capz/manager_image_patch.yaml index 354746ca149a..0876a1db40db 100644 --- a/config/capz/manager_image_patch.yaml +++ b/config/capz/manager_image_patch.yaml @@ -8,5 +8,5 @@ spec: spec: containers: # Change the value of image field below to your controller image URL - - image: localhost:5000/ci-e2e/cluster-api-azure-controller-amd64:20230926200024 + - image: gcr.io/k8s-staging-cluster-api-azure/cluster-api-azure-controller:latest name: manager diff --git a/config/capz/manager_pull_policy.yaml b/config/capz/manager_pull_policy.yaml index cd7ae12c01ea..74a0879c604a 100644 --- a/config/capz/manager_pull_policy.yaml +++ b/config/capz/manager_pull_policy.yaml @@ -8,4 +8,4 @@ spec: spec: containers: - name: manager - imagePullPolicy: IfNotPresent + imagePullPolicy: Always diff --git a/templates/cluster-template-aks-clusterclass-cluster.yaml b/templates/cluster-template-aks-clusterclass-cluster.yaml index 5329e5c338e5..c78efb4b3892 100644 --- a/templates/cluster-template-aks-clusterclass-cluster.yaml +++ b/templates/cluster-template-aks-clusterclass-cluster.yaml @@ -9,7 +9,7 @@ spec: cidrBlocks: - 192.168.0.0/16 topology: - class: default + class: ${CLUSTER_CLASS_NAME} version: ${KUBERNETES_VERSION} workers: machinePools: diff --git a/templates/flavors/aks-clusterclass-cluster/cluster.yaml b/templates/flavors/aks-clusterclass-cluster/cluster.yaml index 5329e5c338e5..c78efb4b3892 100644 --- a/templates/flavors/aks-clusterclass-cluster/cluster.yaml +++ b/templates/flavors/aks-clusterclass-cluster/cluster.yaml @@ -9,7 +9,7 @@ spec: cidrBlocks: - 192.168.0.0/16 topology: - class: default + class: ${CLUSTER_CLASS_NAME} version: ${KUBERNETES_VERSION} workers: machinePools: diff --git a/templates/test/ci/prow-aks-clusterclass/kustomization.yaml b/templates/test/ci/prow-aks-clusterclass/kustomization.yaml index 70b9d47dffad..df8f28bf9cba 100644 --- a/templates/test/ci/prow-aks-clusterclass/kustomization.yaml +++ b/templates/test/ci/prow-aks-clusterclass/kustomization.yaml @@ -8,5 +8,6 @@ patchesStrategicMerge: - patches/tags-aks-clusterclass.yaml - patches/aks-clusterclass-pool0.yaml - patches/aks-clusterclass-pool1.yaml + - patches/cluster.yaml - patches/addons.yaml - patches.yaml diff --git a/templates/test/ci/prow-aks-clusterclass/patches/cluster.yaml b/templates/test/ci/prow-aks-clusterclass/patches/cluster.yaml new file mode 100644 index 000000000000..a1a4b8f8e392 --- /dev/null +++ b/templates/test/ci/prow-aks-clusterclass/patches/cluster.yaml @@ -0,0 +1,7 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: ${CLUSTER_NAME} +spec: + topology: + class: default diff --git a/test/e2e/aks_autoscaler.go b/test/e2e/aks_autoscaler.go index 0a5a887209f3..be3653f0d8ba 100644 --- a/test/e2e/aks_autoscaler.go +++ b/test/e2e/aks_autoscaler.go @@ -36,9 +36,10 @@ import ( ) type AKSAutoscaleSpecInput struct { - Cluster *clusterv1.Cluster - MachinePool *expv1.MachinePool - WaitIntervals []interface{} + Cluster *clusterv1.Cluster + MachinePool *expv1.MachinePool + WaitIntervals []interface{} + isClusterClass bool } func AKSAutoscaleSpec(ctx context.Context, inputGetter func() AKSAutoscaleSpecInput) { @@ -62,7 +63,14 @@ func AKSAutoscaleSpec(ctx context.Context, inputGetter func() AKSAutoscaleSpecIn Expect(err).NotTo(HaveOccurred()) ammp := &infrav1.AzureManagedMachinePool{} - err = mgmtClient.Get(ctx, client.ObjectKeyFromObject(input.MachinePool), ammp) + if input.isClusterClass { + err = bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{ + Namespace: input.MachinePool.Spec.Template.Spec.InfrastructureRef.Namespace, + Name: input.MachinePool.Spec.Template.Spec.InfrastructureRef.Name, + }, ammp) + } else { + err = mgmtClient.Get(ctx, client.ObjectKeyFromObject(input.MachinePool), ammp) + } Expect(err).NotTo(HaveOccurred()) resourceGroupName := amcp.Spec.ResourceGroupName