Manager timeouts and ratelimit

This commit is contained in:
Darren Shepherd
2020-02-01 22:13:32 -07:00
parent a66ef65fd9
commit d80ba54e48
3 changed files with 74 additions and 27 deletions

View File

@@ -1,6 +1,8 @@
package client
import (
"time"
"github.com/rancher/steve/pkg/attributes"
"github.com/rancher/steve/pkg/schemaserver/types"
"k8s.io/client-go/dynamic"
@@ -8,8 +10,9 @@ import (
)
type Factory struct {
client dynamic.Interface
Config *rest.Config
client dynamic.Interface
watchClient dynamic.Interface
Config *rest.Config
}
func NewFactory(cfg *rest.Config) (*Factory, error) {
@@ -20,9 +23,17 @@ func NewFactory(cfg *rest.Config) (*Factory, error) {
if err != nil {
return nil, err
}
newCfg = rest.CopyConfig(cfg)
newCfg.Timeout = 30 * time.Minute
wc, err := dynamic.NewForConfig(newCfg)
if err != nil {
return nil, err
}
return &Factory{
client: c,
Config: newCfg,
client: c,
watchClient: wc,
Config: newCfg,
}, nil
}
@@ -34,3 +45,8 @@ func (p *Factory) Client(ctx *types.APIRequest, s *types.APISchema, namespace st
gvr := attributes.GVR(s)
return p.client.Resource(gvr).Namespace(namespace), nil
}
func (p *Factory) ClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error) {
gvr := attributes.GVR(s)
return p.watchClient.Resource(gvr).Namespace(namespace), nil
}