Skip to content

Commit

Permalink
webhook: fix priority admission conflict (koordinator-sh#1968)
Browse files Browse the repository at this point in the history
Signed-off-by: j4ckstraw <j4ckstraw@foxmail.com>
  • Loading branch information
j4ckstraw authored and 王利杰 committed Mar 25, 2024
1 parent 804799b commit 60e7b46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/webhook/pod/mutating/cluster_colocation_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func (h *PodMutatingHandler) doMutateByColocationProfile(ctx context.Context, po
}
pod.Spec.PriorityClassName = profile.Spec.PriorityClassName
pod.Spec.Priority = pointer.Int32(priorityClass.Value)
pod.Spec.PreemptionPolicy = priorityClass.PreemptionPolicy
}

if profile.Spec.KoordinatorPriority != nil {
Expand Down
11 changes: 10 additions & 1 deletion pkg/webhook/pod/mutating/cluster_colocation_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func newAdmissionRequest(op admissionv1.Operation, object, oldObject runtime.Raw
}

func TestClusterColocationProfileMutatingPod(t *testing.T) {
preemptionPolicy := corev1.PreemptionPolicy("fakePreemptionPolicy")
testCases := []struct {
name string
pod *corev1.Pod
Expand Down Expand Up @@ -210,6 +211,7 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
SchedulerName: "koordinator-scheduler",
Priority: pointer.Int32(extension.PriorityBatchValueMax),
PriorityClassName: "koordinator-batch",
PreemptionPolicy: &preemptionPolicy,
},
},
},
Expand Down Expand Up @@ -304,6 +306,7 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
SchedulerName: "koordinator-scheduler",
Priority: pointer.Int32(extension.PriorityBatchValueMax),
PriorityClassName: "koordinator-batch",
PreemptionPolicy: &preemptionPolicy,
},
},
},
Expand Down Expand Up @@ -394,6 +397,7 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
SchedulerName: "koordinator-scheduler",
Priority: pointer.Int32(extension.PriorityBatchValueMax),
PriorityClassName: "koordinator-batch",
PreemptionPolicy: &preemptionPolicy,
},
},
},
Expand Down Expand Up @@ -531,6 +535,7 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
SchedulerName: "koordinator-scheduler",
Priority: pointer.Int32(extension.PriorityBatchValueMax),
PriorityClassName: "koordinator-batch",
PreemptionPolicy: &preemptionPolicy,
},
},
},
Expand Down Expand Up @@ -930,6 +935,7 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
SchedulerName: "koordinator-scheduler",
Priority: pointer.Int32(extension.PriorityBatchValueMax),
PriorityClassName: "koordinator-batch",
PreemptionPolicy: &preemptionPolicy,
},
},
},
Expand Down Expand Up @@ -1069,6 +1075,7 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
SchedulerName: "koordinator-scheduler",
Priority: pointer.Int32(extension.PriorityBatchValueMax),
PriorityClassName: "koordinator-batch",
PreemptionPolicy: &preemptionPolicy,
},
},
},
Expand Down Expand Up @@ -1208,6 +1215,7 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
SchedulerName: "koordinator-scheduler",
Priority: pointer.Int32(extension.PriorityBatchValueMax),
PriorityClassName: "koordinator-batch",
PreemptionPolicy: &preemptionPolicy,
},
},
},
Expand Down Expand Up @@ -1240,7 +1248,8 @@ func TestClusterColocationProfileMutatingPod(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "koordinator-batch",
},
Value: extension.PriorityBatchValueMax,
Value: extension.PriorityBatchValueMax,
PreemptionPolicy: &preemptionPolicy,
}
err = client.Create(context.TODO(), batchPriorityClass)
assert.NoError(err)
Expand Down

0 comments on commit 60e7b46

Please sign in to comment.