Skip to content

Commit f78c4df

Browse files
authored
Merge pull request kubernetes-retired#443 from k82cn/kb_387
Checked pod group unschedulable event.
2 parents a394034 + c020ee7 commit f78c4df

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

pkg/scheduler/framework/session.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ func (ssn *Session) Preemptable(preemptor *api.TaskInfo, preemptees []*api.TaskI
290290
return victims
291291
}
292292

293-
// Discard discards a job from session, so no plugin/action handles it.
294-
func (ssn *Session) Discard(job *api.JobInfo, event arbcorev1.Event, reason string) error {
293+
// Backoff discards a job from session, so no plugin/action handles it.
294+
func (ssn *Session) Backoff(job *api.JobInfo, event arbcorev1.Event, reason string) error {
295295
if err := ssn.cache.Backoff(job, event, reason); err != nil {
296296
glog.Errorf("Failed to backoff job <%s/%s>: %v",
297297
job.Namespace, job.Name, err)

pkg/scheduler/plugins/gang/gang.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func jobReady(obj interface{}) bool {
6969
func (gp *gangPlugin) OnSessionOpen(ssn *framework.Session) {
7070
for _, job := range ssn.Jobs {
7171
if validTaskNum(job) < job.MinAvailable {
72-
ssn.Discard(job, arbcorev1.UnschedulableEvent, "not enough valid tasks for gang-scheduling")
72+
ssn.Backoff(job, arbcorev1.UnschedulableEvent, "not enough valid tasks for gang-scheduling")
7373
}
7474
}
7575

@@ -139,5 +139,9 @@ func (gp *gangPlugin) OnSessionOpen(ssn *framework.Session) {
139139
}
140140

141141
func (gp *gangPlugin) OnSessionClose(ssn *framework.Session) {
142-
142+
for _, job := range ssn.Jobs {
143+
if len(job.TaskStatusIndex[api.Allocated]) != 0 {
144+
ssn.Backoff(job, arbcorev1.UnschedulableEvent, "not enough resource for job")
145+
}
146+
}
143147
}

test/e2e/job.go

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ var _ = Describe("Job E2E Test", func() {
103103
err = waitPodGroupPending(context, pg)
104104
Expect(err).NotTo(HaveOccurred())
105105

106+
waitPodGroupUnschedulable(context, pg)
107+
Expect(err).NotTo(HaveOccurred())
108+
106109
err = deleteReplicaSet(context, replicaset.Name)
107110
Expect(err).NotTo(HaveOccurred())
108111

0 commit comments

Comments
 (0)