mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
add pod create/delete operation limitations per job sync
This commit is contained in:
parent
cda503fcc9
commit
5fd4ab3dc3
@ -62,6 +62,7 @@ var (
|
|||||||
DefaultJobBackOff = 10 * time.Second
|
DefaultJobBackOff = 10 * time.Second
|
||||||
// MaxJobBackOff is the max backoff period, exported for the e2e test
|
// MaxJobBackOff is the max backoff period, exported for the e2e test
|
||||||
MaxJobBackOff = 360 * time.Second
|
MaxJobBackOff = 360 * time.Second
|
||||||
|
maxPodCreateDeletePerSync = 500
|
||||||
)
|
)
|
||||||
|
|
||||||
// Controller ensures that all Job objects have corresponding pods to
|
// Controller ensures that all Job objects have corresponding pods to
|
||||||
@ -803,6 +804,9 @@ func (jm *Controller) manageJob(job *batch.Job, activePods []*v1.Pod, succeeded
|
|||||||
rmAtLeast = 0
|
rmAtLeast = 0
|
||||||
}
|
}
|
||||||
podsToDelete := activePodsForRemoval(job, activePods, int(rmAtLeast))
|
podsToDelete := activePodsForRemoval(job, activePods, int(rmAtLeast))
|
||||||
|
if len(podsToDelete) > maxPodCreateDeletePerSync {
|
||||||
|
podsToDelete = podsToDelete[:maxPodCreateDeletePerSync]
|
||||||
|
}
|
||||||
if len(podsToDelete) > 0 {
|
if len(podsToDelete) > 0 {
|
||||||
jm.expectations.ExpectDeletions(jobKey, len(podsToDelete))
|
jm.expectations.ExpectDeletions(jobKey, len(podsToDelete))
|
||||||
klog.V(4).InfoS("Too many pods running for job", "job", klog.KObj(job), "deleted", len(podsToDelete), "target", parallelism)
|
klog.V(4).InfoS("Too many pods running for job", "job", klog.KObj(job), "deleted", len(podsToDelete), "target", parallelism)
|
||||||
@ -823,6 +827,10 @@ func (jm *Controller) manageJob(job *batch.Job, activePods []*v1.Pod, succeeded
|
|||||||
return active, nil
|
return active, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if diff > int32(maxPodCreateDeletePerSync) {
|
||||||
|
diff = int32(maxPodCreateDeletePerSync)
|
||||||
|
}
|
||||||
|
|
||||||
jm.expectations.ExpectCreations(jobKey, int(diff))
|
jm.expectations.ExpectCreations(jobKey, int(diff))
|
||||||
errCh := make(chan error, diff)
|
errCh := make(chan error, diff)
|
||||||
klog.V(4).Infof("Too few pods running job %q, need %d, creating %d", jobKey, wantActive, diff)
|
klog.V(4).Infof("Too few pods running job %q, need %d, creating %d", jobKey, wantActive, diff)
|
||||||
|
Loading…
Reference in New Issue
Block a user