diff --git a/store/proxy/proxy_store.go b/store/proxy/proxy_store.go index 4b42dc047..f38cac456 100644 --- a/store/proxy/proxy_store.go +++ b/store/proxy/proxy_store.go @@ -4,6 +4,7 @@ import ( ejson "encoding/json" "net/http" "strings" + "time" "github.com/rancher/norman/types" "github.com/rancher/norman/types/convert" @@ -113,6 +114,11 @@ func (p *Store) getUser(apiContext *types.APIContext) string { } func (p *Store) doAuthed(apiContext *types.APIContext, request *rest.Request) rest.Result { + start := time.Now() + defer func() { + logrus.Debug("GET:", time.Now().Sub(start), p.resourcePlural) + }() + for _, header := range authHeaders { request.SetHeader(header, apiContext.Request.Header[http.CanonicalHeaderKey(header)]...) } @@ -157,7 +163,9 @@ func (p *Store) List(apiContext *types.APIContext, schema *types.Schema, opt *ty req := p.common(namespace, k8sClient.Get()) resultList := &unstructured.UnstructuredList{} + start := time.Now() err = req.Do().Into(resultList) + logrus.Debug("LIST:", time.Now().Sub(start), p.resourcePlural) if err != nil { return nil, err } diff --git a/store/transform/transform.go b/store/transform/transform.go index bd5138ffd..9dbc038f3 100644 --- a/store/transform/transform.go +++ b/store/transform/transform.go @@ -5,11 +5,11 @@ import ( "github.com/rancher/norman/types/convert" ) -type TransformerFunc func(apiContext *types.APIContext, data map[string]interface{}, opt *types.QueryOptions) (map[string]interface{}, error) +type TransformerFunc func(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, opt *types.QueryOptions) (map[string]interface{}, error) -type ListTransformerFunc func(apiContext *types.APIContext, data []map[string]interface{}, opt *types.QueryOptions) ([]map[string]interface{}, error) +type ListTransformerFunc func(apiContext *types.APIContext, schema *types.Schema, data []map[string]interface{}, opt *types.QueryOptions) ([]map[string]interface{}, error) -type StreamTransformerFunc func(apiContext *types.APIContext, data chan map[string]interface{}, opt *types.QueryOptions) (chan map[string]interface{}, error) +type StreamTransformerFunc func(apiContext *types.APIContext, schema *types.Schema, data chan map[string]interface{}, opt *types.QueryOptions) (chan map[string]interface{}, error) type Store struct { Store types.Store @@ -30,7 +30,7 @@ func (s *Store) ByID(apiContext *types.APIContext, schema *types.Schema, id stri if s.Transformer == nil { return data, nil } - return s.Transformer(apiContext, data, &types.QueryOptions{ + return s.Transformer(apiContext, schema, data, &types.QueryOptions{ Options: map[string]string{ "ByID": "true", }, @@ -44,11 +44,11 @@ func (s *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *t } if s.StreamTransformer != nil { - return s.StreamTransformer(apiContext, c, opt) + return s.StreamTransformer(apiContext, schema, c, opt) } return convert.Chan(c, func(data map[string]interface{}) map[string]interface{} { - item, err := s.Transformer(apiContext, data, opt) + item, err := s.Transformer(apiContext, schema, data, opt) if err != nil { return nil } @@ -63,7 +63,7 @@ func (s *Store) List(apiContext *types.APIContext, schema *types.Schema, opt *ty } if s.ListTransformer != nil { - return s.ListTransformer(apiContext, data, opt) + return s.ListTransformer(apiContext, schema, data, opt) } if s.Transformer == nil { @@ -72,7 +72,7 @@ func (s *Store) List(apiContext *types.APIContext, schema *types.Schema, opt *ty var result []map[string]interface{} for _, item := range data { - item, err := s.Transformer(apiContext, item, opt) + item, err := s.Transformer(apiContext, schema, item, opt) if err != nil { return nil, err } @@ -92,7 +92,7 @@ func (s *Store) Create(apiContext *types.APIContext, schema *types.Schema, data if s.Transformer == nil { return data, nil } - return s.Transformer(apiContext, data, nil) + return s.Transformer(apiContext, schema, data, nil) } func (s *Store) Update(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, id string) (map[string]interface{}, error) { @@ -103,7 +103,7 @@ func (s *Store) Update(apiContext *types.APIContext, schema *types.Schema, data if s.Transformer == nil { return data, nil } - return s.Transformer(apiContext, data, nil) + return s.Transformer(apiContext, schema, data, nil) } func (s *Store) Delete(apiContext *types.APIContext, schema *types.Schema, id string) (map[string]interface{}, error) {