mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 11:18:16 +00:00
Slow-start batch pod creation of rs, rc, ds, jobs
Prevent too-large replicas from generating enormous numbers of events by creating only a few pods at a time, then increasing the batch size when pod creations succeed. Stop creating batches of pods when any pod creation errors are encountered.
This commit is contained in:
@@ -324,6 +324,33 @@ func TestSyncReplicaSetCreates(t *testing.T) {
|
||||
validateSyncReplicaSet(t, &fakePodControl, 2, 0, 0)
|
||||
}
|
||||
|
||||
// Tell the rs to create 100 replicas, but simulate a limit (like a quota limit)
|
||||
// of 10, and verify that the rs doesn't make 100 create calls per sync pass
|
||||
func TestSyncReplicaSetCreateFailures(t *testing.T) {
|
||||
fakePodControl := controller.FakePodControl{}
|
||||
fakePodControl.CreateLimit = 10
|
||||
|
||||
labelMap := map[string]string{"foo": "bar"}
|
||||
rs := newReplicaSet(fakePodControl.CreateLimit*10, labelMap)
|
||||
client := fake.NewSimpleClientset(rs)
|
||||
stopCh := make(chan struct{})
|
||||
defer close(stopCh)
|
||||
manager, informers := testNewReplicaSetControllerFromClient(client, stopCh, BurstReplicas)
|
||||
|
||||
informers.Extensions().V1beta1().ReplicaSets().Informer().GetIndexer().Add(rs)
|
||||
|
||||
manager.podControl = &fakePodControl
|
||||
manager.syncReplicaSet(getKey(rs, t))
|
||||
validateSyncReplicaSet(t, &fakePodControl, fakePodControl.CreateLimit, 0, 0)
|
||||
expectedLimit := 0
|
||||
for pass := uint8(0); expectedLimit <= fakePodControl.CreateLimit; pass++ {
|
||||
expectedLimit += controller.SlowStartInitialBatchSize << pass
|
||||
}
|
||||
if fakePodControl.CreateCallCount > expectedLimit {
|
||||
t.Errorf("Unexpected number of create calls. Expected <= %d, saw %d\n", fakePodControl.CreateLimit*2, fakePodControl.CreateCallCount)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusUpdatesWithoutReplicasChange(t *testing.T) {
|
||||
// Setup a fake server to listen for requests, and run the ReplicaSet controller in steady state
|
||||
fakeHandler := utiltesting.FakeHandler{
|
||||
|
||||
Reference in New Issue
Block a user