Merge pull request #11886 from gmarek/ratelimit
Auto commit by PR queue bot
This commit is contained in:
@@ -38,13 +38,6 @@ import (
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// Rate limitations for binding pods to hosts.
|
||||
// TODO: expose these as cmd line flags.
|
||||
const (
|
||||
BindPodsQps = 15
|
||||
BindPodsBurst = 20
|
||||
)
|
||||
|
||||
// ConfigFactory knows how to fill out a scheduler config with its support functions.
|
||||
type ConfigFactory struct {
|
||||
Client *client.Client
|
||||
@@ -71,7 +64,7 @@ type ConfigFactory struct {
|
||||
}
|
||||
|
||||
// Initializes the factory.
|
||||
func NewConfigFactory(client *client.Client) *ConfigFactory {
|
||||
func NewConfigFactory(client *client.Client, rateLimiter util.RateLimiter) *ConfigFactory {
|
||||
c := &ConfigFactory{
|
||||
Client: client,
|
||||
PodQueue: cache.NewFIFO(cache.MetaNamespaceKeyFunc),
|
||||
@@ -85,7 +78,7 @@ func NewConfigFactory(client *client.Client) *ConfigFactory {
|
||||
modeler := scheduler.NewSimpleModeler(&cache.StoreToPodLister{c.PodQueue}, c.ScheduledPodLister)
|
||||
c.modeler = modeler
|
||||
c.PodLister = modeler.PodLister()
|
||||
c.BindPodsRateLimiter = util.NewTokenBucketRateLimiter(BindPodsQps, BindPodsBurst)
|
||||
c.BindPodsRateLimiter = rateLimiter
|
||||
|
||||
// On add/delete to the scheduled pods, remove from the assumed pods.
|
||||
// We construct this here instead of in CreateFromKeys because
|
||||
|
@@ -44,7 +44,7 @@ func TestCreate(t *testing.T) {
|
||||
server := httptest.NewServer(&handler)
|
||||
defer server.Close()
|
||||
client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
|
||||
factory := NewConfigFactory(client)
|
||||
factory := NewConfigFactory(client, nil)
|
||||
factory.Create()
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestCreateFromConfig(t *testing.T) {
|
||||
server := httptest.NewServer(&handler)
|
||||
defer server.Close()
|
||||
client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
|
||||
factory := NewConfigFactory(client)
|
||||
factory := NewConfigFactory(client, nil)
|
||||
|
||||
// Pre-register some predicate and priority functions
|
||||
RegisterFitPredicate("PredicateOne", PredicateOne)
|
||||
@@ -104,7 +104,7 @@ func TestCreateFromEmptyConfig(t *testing.T) {
|
||||
server := httptest.NewServer(&handler)
|
||||
defer server.Close()
|
||||
client := client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()})
|
||||
factory := NewConfigFactory(client)
|
||||
factory := NewConfigFactory(client, nil)
|
||||
|
||||
configData = []byte(`{}`)
|
||||
err := latestschedulerapi.Codec.DecodeInto(configData, &policy)
|
||||
@@ -150,7 +150,7 @@ func TestDefaultErrorFunc(t *testing.T) {
|
||||
mux.Handle(testapi.ResourcePath("pods", "bar", "foo"), &handler)
|
||||
server := httptest.NewServer(mux)
|
||||
defer server.Close()
|
||||
factory := NewConfigFactory(client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()}))
|
||||
factory := NewConfigFactory(client.NewOrDie(&client.Config{Host: server.URL, Version: testapi.Version()}), nil)
|
||||
queue := cache.NewFIFO(cache.MetaNamespaceKeyFunc)
|
||||
podBackoff := podBackoff{
|
||||
perPodBackoff: map[string]*backoffEntry{},
|
||||
|
Reference in New Issue
Block a user