mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Avoid creating more delete collection workers than items to delete
This commit is contained in:
parent
56ad0cefbd
commit
88885b6776
@ -1006,12 +1006,19 @@ func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.Vali
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(items) == 0 {
|
||||
// Nothing to delete, return now
|
||||
return listObj, nil
|
||||
}
|
||||
// Spawn a number of goroutines, so that we can issue requests to storage
|
||||
// in parallel to speed up deletion.
|
||||
// TODO: Make this proportional to the number of items to delete, up to
|
||||
// It is proportional to the number of items to delete, up to
|
||||
// DeleteCollectionWorkers (it doesn't make much sense to spawn 16
|
||||
// workers to delete 10 items).
|
||||
workersNumber := e.DeleteCollectionWorkers
|
||||
if workersNumber > len(items) {
|
||||
workersNumber = len(items)
|
||||
}
|
||||
if workersNumber < 1 {
|
||||
workersNumber = 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user