From 2bb621352e8af58d96df74d3cacf80fd2c9941ab Mon Sep 17 00:00:00 2001 From: Michael McCune Date: Mon, 24 Oct 2022 08:06:14 -0400 Subject: [PATCH] add tolerations and taints for autoscaler workload this change adds taints to the machinesets that are used by the autoscaler tests to ensure that no other workloads are landing on the new machines that are created. --- pkg/autoscaler/autoscaler.go | 15 ++++++++++++++- pkg/framework/machinesets.go | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/autoscaler/autoscaler.go b/pkg/autoscaler/autoscaler.go index 100db0640..07d9a7d14 100644 --- a/pkg/autoscaler/autoscaler.go +++ b/pkg/autoscaler/autoscaler.go @@ -46,7 +46,7 @@ func clusterAutoscalerResource(maxNodesTotal int) *caov1.ClusterAutoscaler { // and that has high least common multiple to avoid a case // when a node is considered to be empty even if there are // pods already scheduled and running on the node. - unneededTimeString := "23s" + unneededTimeString := "60s" return &caov1.ClusterAutoscaler{ ObjectMeta: metav1.ObjectMeta{ Name: "default", @@ -265,6 +265,14 @@ var _ = Describe("[Feature:Machines] Autoscaler should", func() { targetedNodeLabel := fmt.Sprintf("%v-scale-from-zero", autoscalerWorkerNodeRoleLabel) machineSetParams.Labels[targetedNodeLabel] = "" + // wip + machineSetParams.Taints = []corev1.Taint{ + corev1.Taint{ + Key: "scale-from-to-zero", + Effect: corev1.TaintEffectPreferNoSchedule, + }, + } + machineSet, err := framework.CreateMachineSet(client, machineSetParams) Expect(err).ToNot(HaveOccurred()) cleanupObjects[machineSet.GetName()] = machineSet @@ -281,6 +289,11 @@ var _ = Describe("[Feature:Machines] Autoscaler should", func() { uniqueJobName := fmt.Sprintf("%s-scale-from-zero", workloadJobName) By(fmt.Sprintf("Creating scale-out workload %s: jobs: %v, memory: %s", uniqueJobName, expectedReplicas, workloadMemRequest.String())) workload := framework.NewWorkLoad(expectedReplicas, workloadMemRequest, uniqueJobName, autoscalingTestLabel, targetedNodeLabel, "") + // wip + workload.Spec.Template.Spec.Tolerations = append(workload.Spec.Template.Spec.Tolerations, corev1.Toleration{ + Key: "scale-from-to-zero", + Effect: corev1.TaintEffectPreferNoSchedule, + }) cleanupObjects[workload.GetName()] = workload Expect(client.Create(ctx, workload)).Should(Succeed()) diff --git a/pkg/framework/machinesets.go b/pkg/framework/machinesets.go index 24f992e50..323f50ce8 100644 --- a/pkg/framework/machinesets.go +++ b/pkg/framework/machinesets.go @@ -8,6 +8,7 @@ import ( . "github.com/onsi/gomega" machinev1 "github.com/openshift/api/machine/v1beta1" + corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -28,6 +29,7 @@ type MachineSetParams struct { Name string Replicas int32 Labels map[string]string + Taints []corev1.Taint ProviderSpec *machinev1.ProviderSpec } @@ -59,6 +61,7 @@ func BuildMachineSetParams(client runtimeclient.Client, replicas int) MachineSet "e2e.openshift.io": uid.String(), ClusterKey: clusterName, }, + Taints: []corev1.Taint{}, } } @@ -87,6 +90,7 @@ func CreateMachineSet(c client.Client, params MachineSetParams) (*machinev1.Mach Labels: params.Labels, }, ProviderSpec: *params.ProviderSpec, + Taints: params.Taints, }, }, Replicas: pointer.Int32Ptr(params.Replicas),