From 69b87276fea45af033dc1ef02b2240a3423d1b0d 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 ++++++++++++---- test/e2e/azure_test.go | 7 ++++--- 8 files changed, 28 insertions(+), 11 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 354746ca149..0876a1db40d 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 cd7ae12c01e..74a0879c604 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 5329e5c338e..c78efb4b389 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 5329e5c338e..c78efb4b389 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 70b9d47dffa..df8f28bf9cb 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 00000000000..a1a4b8f8e39 --- /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 0a5a887209f..be3653f0d8b 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 diff --git a/test/e2e/azure_test.go b/test/e2e/azure_test.go index f4789be422b..1a294a955dd 100644 --- a/test/e2e/azure_test.go +++ b/test/e2e/azure_test.go @@ -922,9 +922,10 @@ var _ = Describe("Workload cluster creation", func() { By("modifying nodepool autoscaling configuration", func() { AKSAutoscaleSpec(ctx, func() AKSAutoscaleSpecInput { return AKSAutoscaleSpecInput{ - Cluster: result.Cluster, - MachinePool: result.MachinePools[0], - WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"), + Cluster: result.Cluster, + MachinePool: result.MachinePools[0], + WaitIntervals: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"), + isClusterClass: true, } }) })