This is an automated email from the ASF dual-hosted git repository.
pbacsko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git
The following commit(s) were added to refs/heads/master by this push:
new ccfd01e5 [YUNIKORN-2561] Add TopologySpreadConstraints to placeholder
pods (#845)
ccfd01e5 is described below
commit ccfd01e5584f977be6f030d01dcf046af790381a
Author: Jacob Salway <[email protected]>
AuthorDate: Thu Jun 6 18:13:12 2024 +0200
[YUNIKORN-2561] Add TopologySpreadConstraints to placeholder pods (#845)
Closes: #845
Signed-off-by: Peter Bacsko <[email protected]>
---
pkg/cache/amprotocol.go | 17 +++++++++--------
pkg/cache/placeholder.go | 13 +++++++------
pkg/cache/placeholder_test.go | 30 ++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/pkg/cache/amprotocol.go b/pkg/cache/amprotocol.go
index 5f2dd31c..076ca716 100644
--- a/pkg/cache/amprotocol.go
+++ b/pkg/cache/amprotocol.go
@@ -45,14 +45,15 @@ type ApplicationMetadata struct {
}
type TaskGroup struct {
- Name string
- MinMember int32
- Labels map[string]string
- Annotations map[string]string
- MinResource map[string]resource.Quantity
- NodeSelector map[string]string
- Tolerations []v1.Toleration
- Affinity *v1.Affinity
+ Name string
+ MinMember int32
+ Labels map[string]string
+ Annotations map[string]string
+ MinResource map[string]resource.Quantity
+ NodeSelector map[string]string
+ Tolerations []v1.Toleration
+ Affinity *v1.Affinity
+ TopologySpreadConstraints []v1.TopologySpreadConstraint
}
type TaskMetadata struct {
diff --git a/pkg/cache/placeholder.go b/pkg/cache/placeholder.go
index 80562c78..8235bf11 100644
--- a/pkg/cache/placeholder.go
+++ b/pkg/cache/placeholder.go
@@ -113,12 +113,13 @@ func newPlaceholder(placeholderName string, app
*Application, taskGroup TaskGrou
},
},
},
- RestartPolicy:
constants.PlaceholderPodRestartPolicy,
- SchedulerName: constants.SchedulerName,
- NodeSelector: taskGroup.NodeSelector,
- Tolerations: taskGroup.Tolerations,
- Affinity: taskGroup.Affinity,
- PriorityClassName: priorityClassName,
+ RestartPolicy:
constants.PlaceholderPodRestartPolicy,
+ SchedulerName: constants.SchedulerName,
+ NodeSelector: taskGroup.NodeSelector,
+ Tolerations: taskGroup.Tolerations,
+ Affinity: taskGroup.Affinity,
+ TopologySpreadConstraints:
taskGroup.TopologySpreadConstraints,
+ PriorityClassName: priorityClassName,
},
}
diff --git a/pkg/cache/placeholder_test.go b/pkg/cache/placeholder_test.go
index b6cfed15..35914af3 100644
--- a/pkg/cache/placeholder_test.go
+++ b/pkg/cache/placeholder_test.go
@@ -88,6 +88,19 @@ var taskGroups = []TaskGroup{
},
},
},
+ TopologySpreadConstraints: []v1.TopologySpreadConstraint{
+ {
+ MaxSkew: 1,
+ TopologyKey: v1.LabelTopologyZone,
+ WhenUnsatisfiable: v1.DoNotSchedule,
+ LabelSelector: &metav1.LabelSelector{
+ MatchLabels: map[string]string{
+ "labelKey0": "labelKeyValue0",
+ "labelKey1": "labelKeyValue1",
+ },
+ },
+ },
+ },
},
}
@@ -265,3 +278,20 @@ func TestNewPlaceholderWithPriorityClassName(t *testing.T)
{
assert.Equal(t, priority, holder.pod.Spec.Priority)
assert.Equal(t, priorityClassName, holder.pod.Spec.PriorityClassName)
}
+
+func TestNewPlaceholderWithTopologySpreadConstraints(t *testing.T) {
+ mockedSchedulerAPI := newMockSchedulerAPI()
+ app := NewApplication(appID, queue,
+ "bob", testGroups, map[string]string{constants.AppTagNamespace:
namespace}, mockedSchedulerAPI)
+ app.setTaskGroups(taskGroups)
+
+ holder := newPlaceholder("ph-name", app, app.taskGroups[0])
+ assert.Equal(t, len(holder.pod.Spec.TopologySpreadConstraints), 1)
+ assert.Equal(t, holder.pod.Spec.TopologySpreadConstraints[0].MaxSkew,
int32(1))
+ assert.Equal(t,
holder.pod.Spec.TopologySpreadConstraints[0].TopologyKey, v1.LabelTopologyZone)
+ assert.Equal(t,
holder.pod.Spec.TopologySpreadConstraints[0].WhenUnsatisfiable,
v1.DoNotSchedule)
+ assert.DeepEqual(t,
holder.pod.Spec.TopologySpreadConstraints[0].LabelSelector.MatchLabels,
map[string]string{
+ "labelKey0": "labelKeyValue0",
+ "labelKey1": "labelKeyValue1",
+ })
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]