mirror of
https://github.com/rancher/steve.git
synced 2025-05-31 11:04:52 +00:00
Use ligherweight summarized objects for clustercache
This commit is contained in:
parent
72eb648550
commit
4c13c6bd95
@ -10,12 +10,13 @@ import (
|
|||||||
"github.com/rancher/steve/pkg/schemaserver/types"
|
"github.com/rancher/steve/pkg/schemaserver/types"
|
||||||
"github.com/rancher/wrangler/pkg/generic"
|
"github.com/rancher/wrangler/pkg/generic"
|
||||||
"github.com/rancher/wrangler/pkg/merr"
|
"github.com/rancher/wrangler/pkg/merr"
|
||||||
|
"github.com/rancher/wrangler/pkg/summary/client"
|
||||||
|
"github.com/rancher/wrangler/pkg/summary/informer"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
schema2 "k8s.io/apimachinery/pkg/runtime/schema"
|
schema2 "k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
"k8s.io/client-go/dynamic/dynamicinformer"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
)
|
)
|
||||||
@ -52,7 +53,7 @@ type clusterCache struct {
|
|||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
typed map[schema2.GroupVersionKind]cache.SharedIndexInformer
|
typed map[schema2.GroupVersionKind]cache.SharedIndexInformer
|
||||||
informerFactory dynamicinformer.DynamicSharedInformerFactory
|
informerFactory informer.SummarySharedInformerFactory
|
||||||
controllerFactory generic.ControllerManager
|
controllerFactory generic.ControllerManager
|
||||||
watchers map[schema2.GroupVersionResource]*watcher
|
watchers map[schema2.GroupVersionResource]*watcher
|
||||||
workqueue workqueue.DelayingInterface
|
workqueue workqueue.DelayingInterface
|
||||||
@ -62,11 +63,11 @@ type clusterCache struct {
|
|||||||
changeHandlers cancelCollection
|
changeHandlers cancelCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClusterCache(ctx context.Context, client dynamic.Interface) ClusterCache {
|
func NewClusterCache(ctx context.Context, dynamicClient dynamic.Interface) ClusterCache {
|
||||||
c := &clusterCache{
|
c := &clusterCache{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
typed: map[schema2.GroupVersionKind]cache.SharedIndexInformer{},
|
typed: map[schema2.GroupVersionKind]cache.SharedIndexInformer{},
|
||||||
informerFactory: dynamicinformer.NewDynamicSharedInformerFactory(client, 2*time.Hour),
|
informerFactory: informer.NewSummarySharedInformerFactory(client.NewForDynamicClient(dynamicClient), 2*time.Hour),
|
||||||
watchers: map[schema2.GroupVersionResource]*watcher{},
|
watchers: map[schema2.GroupVersionResource]*watcher{},
|
||||||
workqueue: workqueue.NewNamedDelayingQueue("cluster-cache"),
|
workqueue: workqueue.NewNamedDelayingQueue("cluster-cache"),
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/rancher/steve/pkg/schemaserver/types"
|
"github.com/rancher/steve/pkg/schemaserver/types"
|
||||||
"github.com/rancher/wrangler/pkg/summary"
|
"github.com/rancher/wrangler/pkg/summary"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
schema2 "k8s.io/apimachinery/pkg/runtime/schema"
|
schema2 "k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
@ -234,10 +233,7 @@ func getInfo(obj interface{}) (name string, namespace string, revision int, summ
|
|||||||
return "", "", 0, summaryResult, false
|
return "", "", 0, summaryResult, false
|
||||||
}
|
}
|
||||||
|
|
||||||
if unstr, ok := obj.(*unstructured.Unstructured); ok {
|
summaryResult = summary.Summarize(r)
|
||||||
summaryResult = summary.Summarize(unstr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return meta.GetName(), meta.GetNamespace(), revision, summaryResult, true
|
return meta.GetName(), meta.GetNamespace(), revision, summaryResult, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user