mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
JobController doesn't take any actions when being deleted.
This commit is contained in:
parent
7815a3e7bc
commit
95de5a38ea
@ -374,7 +374,7 @@ func (jm *JobController) syncJob(key string) error {
|
|||||||
job.Status.Conditions = append(job.Status.Conditions, newCondition(batch.JobFailed, "DeadlineExceeded", "Job was active longer than specified deadline"))
|
job.Status.Conditions = append(job.Status.Conditions, newCondition(batch.JobFailed, "DeadlineExceeded", "Job was active longer than specified deadline"))
|
||||||
jm.recorder.Event(&job, api.EventTypeNormal, "DeadlineExceeded", "Job was active longer than specified deadline")
|
jm.recorder.Event(&job, api.EventTypeNormal, "DeadlineExceeded", "Job was active longer than specified deadline")
|
||||||
} else {
|
} else {
|
||||||
if jobNeedsSync {
|
if jobNeedsSync && job.DeletionTimestamp == nil {
|
||||||
active = jm.manageJob(activePods, succeeded, &job)
|
active = jm.manageJob(activePods, succeeded, &job)
|
||||||
}
|
}
|
||||||
completions := succeeded
|
completions := succeeded
|
@ -107,6 +107,7 @@ func TestControllerSyncJob(t *testing.T) {
|
|||||||
// job setup
|
// job setup
|
||||||
parallelism int32
|
parallelism int32
|
||||||
completions int32
|
completions int32
|
||||||
|
deleting bool
|
||||||
|
|
||||||
// pod setup
|
// pod setup
|
||||||
podControllerError error
|
podControllerError error
|
||||||
@ -124,90 +125,95 @@ func TestControllerSyncJob(t *testing.T) {
|
|||||||
expectedComplete bool
|
expectedComplete bool
|
||||||
}{
|
}{
|
||||||
"job start": {
|
"job start": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 0, 0, 0,
|
nil, 0, 0, 0, 0,
|
||||||
2, 0, 2, 0, 0, false,
|
2, 0, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"WQ job start": {
|
"WQ job start": {
|
||||||
2, -1,
|
2, -1, false,
|
||||||
nil, 0, 0, 0, 0,
|
nil, 0, 0, 0, 0,
|
||||||
2, 0, 2, 0, 0, false,
|
2, 0, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"pending pods": {
|
"pending pods": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 2, 0, 0, 0,
|
nil, 2, 0, 0, 0,
|
||||||
0, 0, 2, 0, 0, false,
|
0, 0, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"correct # of pods": {
|
"correct # of pods": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 2, 0, 0,
|
nil, 0, 2, 0, 0,
|
||||||
0, 0, 2, 0, 0, false,
|
0, 0, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"WQ job: correct # of pods": {
|
"WQ job: correct # of pods": {
|
||||||
2, -1,
|
2, -1, false,
|
||||||
nil, 0, 2, 0, 0,
|
nil, 0, 2, 0, 0,
|
||||||
0, 0, 2, 0, 0, false,
|
0, 0, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"too few active pods": {
|
"too few active pods": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 1, 1, 0,
|
nil, 0, 1, 1, 0,
|
||||||
1, 0, 2, 1, 0, false,
|
1, 0, 2, 1, 0, false,
|
||||||
},
|
},
|
||||||
"too few active pods with a dynamic job": {
|
"too few active pods with a dynamic job": {
|
||||||
2, -1,
|
2, -1, false,
|
||||||
nil, 0, 1, 0, 0,
|
nil, 0, 1, 0, 0,
|
||||||
1, 0, 2, 0, 0, false,
|
1, 0, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"too few active pods, with controller error": {
|
"too few active pods, with controller error": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
fmt.Errorf("Fake error"), 0, 1, 1, 0,
|
fmt.Errorf("Fake error"), 0, 1, 1, 0,
|
||||||
0, 0, 1, 1, 0, false,
|
0, 0, 1, 1, 0, false,
|
||||||
},
|
},
|
||||||
"too many active pods": {
|
"too many active pods": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 3, 0, 0,
|
nil, 0, 3, 0, 0,
|
||||||
0, 1, 2, 0, 0, false,
|
0, 1, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"too many active pods, with controller error": {
|
"too many active pods, with controller error": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
fmt.Errorf("Fake error"), 0, 3, 0, 0,
|
fmt.Errorf("Fake error"), 0, 3, 0, 0,
|
||||||
0, 0, 3, 0, 0, false,
|
0, 0, 3, 0, 0, false,
|
||||||
},
|
},
|
||||||
"failed pod": {
|
"failed pod": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 1, 1, 1,
|
nil, 0, 1, 1, 1,
|
||||||
1, 0, 2, 1, 1, false,
|
1, 0, 2, 1, 1, false,
|
||||||
},
|
},
|
||||||
"job finish": {
|
"job finish": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 0, 5, 0,
|
nil, 0, 0, 5, 0,
|
||||||
0, 0, 0, 5, 0, true,
|
0, 0, 0, 5, 0, true,
|
||||||
},
|
},
|
||||||
"WQ job finishing": {
|
"WQ job finishing": {
|
||||||
2, -1,
|
2, -1, false,
|
||||||
nil, 0, 1, 1, 0,
|
nil, 0, 1, 1, 0,
|
||||||
0, 0, 1, 1, 0, false,
|
0, 0, 1, 1, 0, false,
|
||||||
},
|
},
|
||||||
"WQ job all finished": {
|
"WQ job all finished": {
|
||||||
2, -1,
|
2, -1, false,
|
||||||
nil, 0, 0, 2, 0,
|
nil, 0, 0, 2, 0,
|
||||||
0, 0, 0, 2, 0, true,
|
0, 0, 0, 2, 0, true,
|
||||||
},
|
},
|
||||||
"WQ job all finished despite one failure": {
|
"WQ job all finished despite one failure": {
|
||||||
2, -1,
|
2, -1, false,
|
||||||
nil, 0, 0, 1, 1,
|
nil, 0, 0, 1, 1,
|
||||||
0, 0, 0, 1, 1, true,
|
0, 0, 0, 1, 1, true,
|
||||||
},
|
},
|
||||||
"more active pods than completions": {
|
"more active pods than completions": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 10, 0, 0,
|
nil, 0, 10, 0, 0,
|
||||||
0, 8, 2, 0, 0, false,
|
0, 8, 2, 0, 0, false,
|
||||||
},
|
},
|
||||||
"status change": {
|
"status change": {
|
||||||
2, 5,
|
2, 5, false,
|
||||||
nil, 0, 2, 2, 0,
|
nil, 0, 2, 2, 0,
|
||||||
0, 0, 2, 2, 0, false,
|
0, 0, 2, 2, 0, false,
|
||||||
},
|
},
|
||||||
|
"deleting job": {
|
||||||
|
2, 5, true,
|
||||||
|
nil, 1, 1, 1, 0,
|
||||||
|
0, 0, 2, 1, 0, false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, tc := range testCases {
|
for name, tc := range testCases {
|
||||||
@ -225,6 +231,10 @@ func TestControllerSyncJob(t *testing.T) {
|
|||||||
|
|
||||||
// job & pods setup
|
// job & pods setup
|
||||||
job := newJob(tc.parallelism, tc.completions)
|
job := newJob(tc.parallelism, tc.completions)
|
||||||
|
if tc.deleting {
|
||||||
|
now := unversioned.Now()
|
||||||
|
job.DeletionTimestamp = &now
|
||||||
|
}
|
||||||
manager.jobStore.Store.Add(job)
|
manager.jobStore.Store.Add(job)
|
||||||
for _, pod := range newPodList(tc.pendingPods, api.PodPending, job) {
|
for _, pod := range newPodList(tc.pendingPods, api.PodPending, job) {
|
||||||
manager.podStore.Indexer.Add(&pod)
|
manager.podStore.Indexer.Add(&pod)
|
Loading…
Reference in New Issue
Block a user