Skip to content

Commit

Permalink
add tolerations and taints for autoscaler workload
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
elmiko committed Oct 24, 2022
1 parent dc312c4 commit 2bb6213
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/autoscaler/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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())

Expand Down
4 changes: 4 additions & 0 deletions pkg/framework/machinesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -28,6 +29,7 @@ type MachineSetParams struct {
Name string
Replicas int32
Labels map[string]string
Taints []corev1.Taint
ProviderSpec *machinev1.ProviderSpec
}

Expand Down Expand Up @@ -59,6 +61,7 @@ func BuildMachineSetParams(client runtimeclient.Client, replicas int) MachineSet
"e2e.openshift.io": uid.String(),
ClusterKey: clusterName,
},
Taints: []corev1.Taint{},
}
}

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 2bb6213

Please sign in to comment.