From 0db96a0ac31adcea8c041f3174ab5a94cdf53ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Skocze=C5=84?= Date: Mon, 14 Oct 2024 08:06:21 +0000 Subject: [PATCH] Add scheduler_perf test case for AssignedPodAdd event handling --- .../config/event_handling/podadd-node.yaml | 14 ++++ .../podadd-pod-interpodaffinity.yaml | 18 +++++ .../podadd-pod-podtopologyspread.yaml | 26 +++++++ .../podadd-pod-unblocker-affinity.yaml | 10 +++ .../podadd-pod-unblocker-topology.yaml | 19 +++++ .../event_handling/podadd-pod-with-label.yaml | 10 +++ .../config/performance-config.yaml | 72 +++++++++++++++++++ 7 files changed, 169 insertions(+) create mode 100644 test/integration/scheduler_perf/config/event_handling/podadd-node.yaml create mode 100644 test/integration/scheduler_perf/config/event_handling/podadd-pod-interpodaffinity.yaml create mode 100644 test/integration/scheduler_perf/config/event_handling/podadd-pod-podtopologyspread.yaml create mode 100644 test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-affinity.yaml create mode 100644 test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-topology.yaml create mode 100644 test/integration/scheduler_perf/config/event_handling/podadd-pod-with-label.yaml diff --git a/test/integration/scheduler_perf/config/event_handling/podadd-node.yaml b/test/integration/scheduler_perf/config/event_handling/podadd-node.yaml new file mode 100644 index 00000000000..0e566e71889 --- /dev/null +++ b/test/integration/scheduler_perf/config/event_handling/podadd-node.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Node +metadata: + generateName: scheduler-perf- +spec: {} +status: + capacity: + pods: "3000" + cpu: "4" + memory: 32Gi + conditions: + - status: "True" + type: Ready + phase: Running diff --git a/test/integration/scheduler_perf/config/event_handling/podadd-pod-interpodaffinity.yaml b/test/integration/scheduler_perf/config/event_handling/podadd-pod-interpodaffinity.yaml new file mode 100644 index 00000000000..b388fa0e6d3 --- /dev/null +++ b/test/integration/scheduler_perf/config/event_handling/podadd-pod-interpodaffinity.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + generateName: pod-interpodaffinity- + labels: + type: unsched +spec: + affinity: + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + color: yellow-{{ .Index }} + topologyKey: kubernetes.io/hostname + namespaces: ["interpodaffinity"] + containers: + - image: registry.k8s.io/pause:3.10 + name: pause diff --git a/test/integration/scheduler_perf/config/event_handling/podadd-pod-podtopologyspread.yaml b/test/integration/scheduler_perf/config/event_handling/podadd-pod-podtopologyspread.yaml new file mode 100644 index 00000000000..09c4c9968f7 --- /dev/null +++ b/test/integration/scheduler_perf/config/event_handling/podadd-pod-podtopologyspread.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: Pod +metadata: + generateName: pod-podtopologyspread- + labels: + type: unsched + topology: blue +spec: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + color: green + topologyKey: kubernetes.io/hostname + namespaces: ["podtopologyspread"] + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + topology: blue + containers: + - image: registry.k8s.io/pause:3.10 + name: pause diff --git a/test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-affinity.yaml b/test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-affinity.yaml new file mode 100644 index 00000000000..16629c4af8c --- /dev/null +++ b/test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-affinity.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + generateName: pod-unblocker-affinity- + labels: + color: yellow-{{ .Index }} +spec: + containers: + - image: registry.k8s.io/pause:3.10 + name: pause diff --git a/test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-topology.yaml b/test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-topology.yaml new file mode 100644 index 00000000000..8ffe9074c1c --- /dev/null +++ b/test/integration/scheduler_perf/config/event_handling/podadd-pod-unblocker-topology.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Pod +metadata: + generateName: pod-unblocker-topology- + labels: + topology: blue + color: green +spec: + affinity: + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + color: green + topologyKey: kubernetes.io/hostname + namespaces: ["podtopologyspread"] + containers: + - image: registry.k8s.io/pause:3.10 + name: pause diff --git a/test/integration/scheduler_perf/config/event_handling/podadd-pod-with-label.yaml b/test/integration/scheduler_perf/config/event_handling/podadd-pod-with-label.yaml new file mode 100644 index 00000000000..ff92ce04469 --- /dev/null +++ b/test/integration/scheduler_perf/config/event_handling/podadd-pod-with-label.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + generateName: pod-with-label- + labels: + color: green +spec: + containers: + - image: registry.k8s.io/pause:3.10 + name: pause diff --git a/test/integration/scheduler_perf/config/performance-config.yaml b/test/integration/scheduler_perf/config/performance-config.yaml index 90c089ee7b9..bc32fba4664 100644 --- a/test/integration/scheduler_perf/config/performance-config.yaml +++ b/test/integration/scheduler_perf/config/performance-config.yaml @@ -1881,3 +1881,75 @@ params: nodes: 100 measurePods: 1000 # Must be initNodes * 10 + +# This test case is used to measure the performance of queuing hints when handling the AssignedPodAdd events. +# First, two nodes are created. Then, one pod is created and scheduled on one of the nodes. +# Next, group of topology spreading pods tries to be scheduled, but they can only fill one node, +# because of the anti affinity to the pod on the second node. +# Then, group of interpodaffinity pods is created and wait for pods with matching labels to be scheduled first. +# Next, new pods are scheduled that unblock the previously unschedulable pods, by balancing the topology +# and scheduling pods with matching labels to the intepodaffinity pods. +# Plugins covered: InterPodAffinity and PodTopologySpread. +- name: EventHandlingPodAdd + featureGates: + SchedulerQueueingHints: true + workloadTemplate: + # Create two nodes with enough capacity. + - opcode: createNodes + count: 2 + nodeTemplatePath: config/event_handling/podadd-node.yaml + # Create one pod with label that will block topology spreading pods + # from being scheduled on one node using pod anti affinity. + - opcode: createPods + count: 1 + podTemplatePath: config/event_handling/podadd-pod-with-label.yaml + namespace: podtopologyspread + # Collect metrics for unsched pods created below. + - opcode: startCollectingMetrics + name: unschedPods + namespaces: [podtopologyspread, interpodaffinity] + labelSelector: + type: unsched + # Create pods blocked using PodTopologySpread plugin. + # Max skew is configured to 1, so more pods need to be created on the first node + # (with the pod created above), to fill up the second node with these pods. + - opcode: createPods + countParam: $measurePods + podTemplatePath: config/event_handling/podadd-pod-podtopologyspread.yaml + skipWaitToCompletion: true + namespace: podtopologyspread + # Create pods blocked using InterPodAffinity plugin. + # They don't have the affinity to themselves, + # so have to wait for another pods with matching labels to be created at first. + - opcode: createPods + countParam: $measurePods + podTemplatePath: config/event_handling/podadd-pod-interpodaffinity.yaml + skipWaitToCompletion: true + namespace: interpodaffinity + # Wait for unschedulable pods to be processed by the scheduler. + - opcode: barrier + stageRequirement: Attempted + labelSelector: + type: unsched + # Create pods that will get scheduled on the node with the first pod created with matching label. + # Their creation will gradually unblock topology spreading pods and make them schedulable on the second node. + - opcode: createPods + countParam: $measurePods + podTemplatePath: config/event_handling/podadd-pod-unblocker-topology.yaml + namespace: podtopologyspread + # Create pods with matching labels to the affinity of previously created interpodaffinity pods. + # Each of them will unblock one pod and make it schedulable. + - opcode: createPods + countParam: $measurePods + podTemplatePath: config/event_handling/podadd-pod-unblocker-affinity.yaml + namespace: interpodaffinity + # Wait for previously unschedulable pods to be scheduled. + - opcode: barrier + labelSelector: + type: unsched + - opcode: stopCollectingMetrics + workloads: + - name: 1000Pods + labels: [performance, short] + params: + measurePods: 1000