This is an automated email from the ASF dual-hosted git repository.
mani 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 14e86c55 [YUNIKORN-1953] replace priority with priorityclass in
placeholder (#666)
14e86c55 is described below
commit 14e86c5548c8c1d201f1e02059dbc6eb52443e83
Author: PoAn Yang <[email protected]>
AuthorDate: Tue Sep 5 17:27:45 2023 +0530
[YUNIKORN-1953] replace priority with priorityclass in placeholder (#666)
Closes: #666
Signed-off-by: Manikandan R <[email protected]>
---
pkg/cache/placeholder.go | 16 ++++++++--------
pkg/cache/placeholder_manager_test.go | 19 ++++++++++---------
pkg/cache/placeholder_test.go | 17 ++++++++++++-----
3 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/pkg/cache/placeholder.go b/pkg/cache/placeholder.go
index f3b91bd8..559864db 100644
--- a/pkg/cache/placeholder.go
+++ b/pkg/cache/placeholder.go
@@ -79,9 +79,9 @@ func newPlaceholder(placeholderName string, app *Application,
taskGroup interfac
}
}
- var priority *int32
+ var priorityClassName string
if task := app.GetOriginatingTask(); task != nil {
- priority = task.GetTaskPod().Spec.Priority
+ priorityClassName = task.GetTaskPod().Spec.PriorityClassName
}
// prepare the resource lists
@@ -116,12 +116,12 @@ func newPlaceholder(placeholderName string, app
*Application, taskGroup interfac
},
},
},
- RestartPolicy: constants.PlaceholderPodRestartPolicy,
- SchedulerName: constants.SchedulerName,
- NodeSelector: taskGroup.NodeSelector,
- Tolerations: taskGroup.Tolerations,
- Affinity: taskGroup.Affinity,
- Priority: priority,
+ RestartPolicy:
constants.PlaceholderPodRestartPolicy,
+ SchedulerName: constants.SchedulerName,
+ NodeSelector: taskGroup.NodeSelector,
+ Tolerations: taskGroup.Tolerations,
+ Affinity: taskGroup.Affinity,
+ PriorityClassName: priorityClassName,
},
}
diff --git a/pkg/cache/placeholder_manager_test.go
b/pkg/cache/placeholder_manager_test.go
index 978f1b75..dfba30b0 100644
--- a/pkg/cache/placeholder_manager_test.go
+++ b/pkg/cache/placeholder_manager_test.go
@@ -36,9 +36,10 @@ import (
)
const (
- appID = "app01"
- queue = "root.default"
- namespace = "test"
+ appID = "app01"
+ queue = "root.default"
+ namespace = "test"
+ priorityClassName = "test-priority-class"
)
func TestNewPlaceholderManager(t *testing.T) {
@@ -90,11 +91,12 @@ func TestCreateAppPlaceholdersWithExistingPods(t
*testing.T) {
assert.Equal(t, (*v1.Pod)(nil), createdPods["tg-test-group-1-app01-0"],
"Pod should not have been created")
assert.Equal(t, (*v1.Pod)(nil), createdPods["tg-test-group-1-app01-1"],
"Pod should not have been created")
assert.Equal(t, (*v1.Pod)(nil), createdPods["tg-test-group-1-app02-0"],
"Pod should not have been created")
+ var priority *int32
for _, tg := range []string{"tg-test-group-1-app01-",
"tg-test-group-2-app01-"} {
for i := 2; i <= 9; i++ {
podName := tg + strconv.Itoa(i)
- priority := createdPods[podName].Spec.Priority
- assert.Equal(t, *priority, int32(10), "Pod should not
have been created")
+ assert.Equal(t, priority,
createdPods[podName].Spec.Priority, "Priority should not be set")
+ assert.Equal(t, priorityClassName,
createdPods[podName].Spec.PriorityClassName, "priority class name should be
set")
}
}
}
@@ -114,7 +116,8 @@ func createAndCheckPlaceholderCreate(mockedAPIProvider
*client.MockedAPIProvider
for _, tg := range []string{"tg-test-group-1-app01-",
"tg-test-group-2-app01-"} {
for i := 2; i <= 9; i++ {
podName := tg + strconv.Itoa(i)
- assert.Equal(t, priority,
createdPods[podName].Spec.Priority, "Pod should not have been created")
+ assert.Equal(t, priority,
createdPods[podName].Spec.Priority, "Priority should not be set")
+ assert.Equal(t, "",
createdPods[podName].Spec.PriorityClassName, "Priority class name should be
empty")
}
}
return createdPods
@@ -166,8 +169,6 @@ func createAppWIthTaskGroupForTest() *Application {
func createAppWIthTaskGroupAndPodsForTest() *Application {
app := createAppWIthTaskGroupForTest()
mockedContext := initContextForTest()
- priority := int32(10)
- specPriority := &priority
pod1 := &v1.Pod{
TypeMeta: apis.TypeMeta{
Kind: "Pod",
@@ -178,7 +179,7 @@ func createAppWIthTaskGroupAndPodsForTest() *Application {
UID: "UID-01",
},
Spec: v1.PodSpec{
- Priority: specPriority,
+ PriorityClassName: priorityClassName,
},
}
pod2 := &v1.Pod{
diff --git a/pkg/cache/placeholder_test.go b/pkg/cache/placeholder_test.go
index e7ebdc09..0be88637 100644
--- a/pkg/cache/placeholder_test.go
+++ b/pkg/cache/placeholder_test.go
@@ -128,6 +128,7 @@ func TestNewPlaceholder(t *testing.T) {
assert.Equal(t, "secret2", holder.pod.Spec.ImagePullSecrets[1].Name)
var priority *int32
assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, "", holder.pod.Spec.PriorityClassName)
}
func TestNewPlaceholderWithLabelsAndAnnotations(t *testing.T) {
@@ -152,6 +153,7 @@ func TestNewPlaceholderWithLabelsAndAnnotations(t
*testing.T) {
assert.NilError(t, err, "taskGroupsDef unmarshal failed")
var priority *int32
assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, "", holder.pod.Spec.PriorityClassName)
}
func TestNewPlaceholderWithNodeSelectors(t *testing.T) {
@@ -166,6 +168,7 @@ func TestNewPlaceholderWithNodeSelectors(t *testing.T) {
assert.Equal(t, holder.pod.Spec.NodeSelector["nodeState"], "healthy")
var priority *int32
assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, "", holder.pod.Spec.PriorityClassName)
}
func TestNewPlaceholderWithTolerations(t *testing.T) {
@@ -183,6 +186,7 @@ func TestNewPlaceholderWithTolerations(t *testing.T) {
assert.Equal(t, tlr.Effect, v1.TaintEffectNoSchedule)
var priority *int32
assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, "", holder.pod.Spec.PriorityClassName)
}
func TestNewPlaceholderWithAffinity(t *testing.T) {
@@ -202,6 +206,7 @@ func TestNewPlaceholderWithAffinity(t *testing.T) {
assert.Equal(t, term[0].LabelSelector.MatchExpressions[0].Values[0],
"securityscan")
var priority *int32
assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, "", holder.pod.Spec.PriorityClassName)
}
func TestNewPlaceholderTaskGroupsDefinition(t *testing.T) {
@@ -220,6 +225,7 @@ func TestNewPlaceholderTaskGroupsDefinition(t *testing.T) {
assert.Equal(t, "taskGroupsDef",
holder.pod.Annotations[constants.AnnotationTaskGroups])
var priority *int32
assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, "", holder.pod.Spec.PriorityClassName)
}
func TestNewPlaceholderExtendedResources(t *testing.T) {
@@ -234,16 +240,15 @@ func TestNewPlaceholderExtendedResources(t *testing.T) {
assert.Equal(t,
holder.pod.Spec.Containers[0].Resources.Limits[hugepages],
holder.pod.Spec.Containers[0].Resources.Requests[hugepages], "hugepages:
expected same value for request and limit")
var priority *int32
assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, "", holder.pod.Spec.PriorityClassName)
}
-func TestNewPlaceholderWithPriority(t *testing.T) {
+func TestNewPlaceholderWithPriorityClassName(t *testing.T) {
mockedSchedulerAPI := newMockSchedulerAPI()
app := NewApplication(appID, queue,
"bob", testGroups, map[string]string{constants.AppTagNamespace:
namespace}, mockedSchedulerAPI)
app.setTaskGroups(taskGroups)
mockedContext := initContextForTest()
- priority := int32(10)
- specPriority := &priority
pod1 := &v1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
@@ -254,7 +259,7 @@ func TestNewPlaceholderWithPriority(t *testing.T) {
UID: "UID-01",
},
Spec: v1.PodSpec{
- Priority: specPriority,
+ PriorityClassName: priorityClassName,
},
}
taskID1 := "task1-01"
@@ -270,5 +275,7 @@ func TestNewPlaceholderWithPriority(t *testing.T) {
assert.Equal(t, len(holder.pod.Spec.Containers[0].Resources.Limits), 2,
"limit for extended resource not found")
assert.Equal(t, holder.pod.Spec.Containers[0].Resources.Limits[gpu],
holder.pod.Spec.Containers[0].Resources.Requests[gpu], "gpu: expected same
value for request and limit")
assert.Equal(t,
holder.pod.Spec.Containers[0].Resources.Limits[hugepages],
holder.pod.Spec.Containers[0].Resources.Requests[hugepages], "hugepages:
expected same value for request and limit")
- assert.Equal(t, priority, *holder.pod.Spec.Priority)
+ var priority *int32
+ assert.Equal(t, priority, holder.pod.Spec.Priority)
+ assert.Equal(t, priorityClassName, holder.pod.Spec.PriorityClassName)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]