Merge pull request #2089 from dddddai/transform
Adopt transform func to save memory
This commit is contained in:
commit
62a4b4391f
|
@ -17,6 +17,7 @@ import (
|
||||||
"k8s.io/component-base/term"
|
"k8s.io/component-base/term"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
controllerruntime "sigs.k8s.io/controller-runtime"
|
controllerruntime "sigs.k8s.io/controller-runtime"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/cache"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
|
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/healthz"
|
"sigs.k8s.io/controller-runtime/pkg/healthz"
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ import (
|
||||||
"github.com/karmada-io/karmada/pkg/sharedcli/klogflag"
|
"github.com/karmada-io/karmada/pkg/sharedcli/klogflag"
|
||||||
"github.com/karmada-io/karmada/pkg/sharedcli/profileflag"
|
"github.com/karmada-io/karmada/pkg/sharedcli/profileflag"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
"github.com/karmada-io/karmada/pkg/util/fedinformer"
|
||||||
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
||||||
"github.com/karmada-io/karmada/pkg/util/fedinformer/typedmanager"
|
"github.com/karmada-io/karmada/pkg/util/fedinformer/typedmanager"
|
||||||
"github.com/karmada-io/karmada/pkg/util/gclient"
|
"github.com/karmada-io/karmada/pkg/util/gclient"
|
||||||
|
@ -188,6 +190,9 @@ func run(ctx context.Context, karmadaConfig karmadactl.KarmadaConfig, opts *opti
|
||||||
clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs,
|
clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
NewCache: cache.BuilderWithOptions(cache.Options{
|
||||||
|
DefaultTransform: fedinformer.StripUnusedFields,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to build controller manager: %w", err)
|
return fmt.Errorf("failed to build controller manager: %w", err)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"k8s.io/component-base/term"
|
"k8s.io/component-base/term"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
controllerruntime "sigs.k8s.io/controller-runtime"
|
controllerruntime "sigs.k8s.io/controller-runtime"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/cache"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
|
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/event"
|
"sigs.k8s.io/controller-runtime/pkg/event"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/healthz"
|
"sigs.k8s.io/controller-runtime/pkg/healthz"
|
||||||
|
@ -48,6 +49,7 @@ import (
|
||||||
"github.com/karmada-io/karmada/pkg/sharedcli/klogflag"
|
"github.com/karmada-io/karmada/pkg/sharedcli/klogflag"
|
||||||
"github.com/karmada-io/karmada/pkg/sharedcli/profileflag"
|
"github.com/karmada-io/karmada/pkg/sharedcli/profileflag"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
"github.com/karmada-io/karmada/pkg/util/fedinformer"
|
||||||
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
||||||
"github.com/karmada-io/karmada/pkg/util/fedinformer/typedmanager"
|
"github.com/karmada-io/karmada/pkg/util/fedinformer/typedmanager"
|
||||||
"github.com/karmada-io/karmada/pkg/util/gclient"
|
"github.com/karmada-io/karmada/pkg/util/gclient"
|
||||||
|
@ -134,6 +136,9 @@ func Run(ctx context.Context, opts *options.Options) error {
|
||||||
schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Namespace"}.GroupKind().String(): opts.ConcurrentNamespaceSyncs,
|
schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Namespace"}.GroupKind().String(): opts.ConcurrentNamespaceSyncs,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
NewCache: cache.BuilderWithOptions(cache.Options{
|
||||||
|
DefaultTransform: fedinformer.StripUnusedFields,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("failed to build controller manager: %v", err)
|
klog.Errorf("failed to build controller manager: %v", err)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
clusterlister "github.com/karmada-io/karmada/pkg/generated/listers/cluster/v1alpha1"
|
clusterlister "github.com/karmada-io/karmada/pkg/generated/listers/cluster/v1alpha1"
|
||||||
worklister "github.com/karmada-io/karmada/pkg/generated/listers/work/v1alpha2"
|
worklister "github.com/karmada-io/karmada/pkg/generated/listers/work/v1alpha2"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
"github.com/karmada-io/karmada/pkg/util/fedinformer"
|
||||||
"github.com/karmada-io/karmada/pkg/util/gclient"
|
"github.com/karmada-io/karmada/pkg/util/gclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,6 +71,10 @@ func NewDescheduler(karmadaClient karmadaclientset.Interface, kubeClient kuberne
|
||||||
unschedulableThreshold: opts.UnschedulableThreshold.Duration,
|
unschedulableThreshold: opts.UnschedulableThreshold.Duration,
|
||||||
deschedulingInterval: opts.DeschedulingInterval.Duration,
|
deschedulingInterval: opts.DeschedulingInterval.Duration,
|
||||||
}
|
}
|
||||||
|
// ignore the error here because the informers haven't been started
|
||||||
|
_ = desched.bindingInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = desched.clusterInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
|
||||||
schedulerEstimatorWorkerOptions := util.Options{
|
schedulerEstimatorWorkerOptions := util.Options{
|
||||||
Name: "scheduler-estimator",
|
Name: "scheduler-estimator",
|
||||||
KeyFunc: nil,
|
KeyFunc: nil,
|
||||||
|
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"github.com/karmada-io/karmada/pkg/estimator/server/replica"
|
"github.com/karmada-io/karmada/pkg/estimator/server/replica"
|
||||||
estimatorservice "github.com/karmada-io/karmada/pkg/estimator/service"
|
estimatorservice "github.com/karmada-io/karmada/pkg/estimator/service"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
"github.com/karmada-io/karmada/pkg/util/fedinformer"
|
||||||
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
||||||
"github.com/karmada-io/karmada/pkg/util/fedinformer/keys"
|
"github.com/karmada-io/karmada/pkg/util/fedinformer/keys"
|
||||||
"github.com/karmada-io/karmada/pkg/util/helper"
|
"github.com/karmada-io/karmada/pkg/util/helper"
|
||||||
|
@ -92,6 +93,10 @@ func NewEstimatorServer(
|
||||||
},
|
},
|
||||||
parallelizer: lifted.NewParallelizer(opts.Parallelism),
|
parallelizer: lifted.NewParallelizer(opts.Parallelism),
|
||||||
}
|
}
|
||||||
|
// ignore the error here because the informers haven't been started
|
||||||
|
_ = es.nodeInformer.Informer().SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = es.podInformer.Informer().SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = informerFactory.Apps().V1().ReplicaSets().Informer().SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
|
||||||
// Establish a connection between the pods and their assigned nodes.
|
// Establish a connection between the pods and their assigned nodes.
|
||||||
_ = es.podInformer.Informer().AddIndexers(cache.Indexers{
|
_ = es.podInformer.Informer().AddIndexers(cache.Indexers{
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
||||||
"github.com/karmada-io/karmada/pkg/scheduler/metrics"
|
"github.com/karmada-io/karmada/pkg/scheduler/metrics"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
"github.com/karmada-io/karmada/pkg/util/fedinformer"
|
||||||
"github.com/karmada-io/karmada/pkg/util/gclient"
|
"github.com/karmada-io/karmada/pkg/util/gclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,6 +57,12 @@ func (s *Scheduler) addAllEventHandlers() {
|
||||||
DeleteFunc: s.deleteCluster,
|
DeleteFunc: s.deleteCluster,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
// ignore the error here because the informers haven't been started
|
||||||
|
_ = bindingInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = policyInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = clusterBindingInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = clusterPolicyInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = memClusterInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
|
||||||
eventBroadcaster := record.NewBroadcaster()
|
eventBroadcaster := record.NewBroadcaster()
|
||||||
eventBroadcaster.StartStructuredLogging(0)
|
eventBroadcaster.StartStructuredLogging(0)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
clusterlister "github.com/karmada-io/karmada/pkg/generated/listers/cluster/v1alpha1"
|
clusterlister "github.com/karmada-io/karmada/pkg/generated/listers/cluster/v1alpha1"
|
||||||
"github.com/karmada-io/karmada/pkg/search/backendstore"
|
"github.com/karmada-io/karmada/pkg/search/backendstore"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
"github.com/karmada-io/karmada/pkg/util/fedinformer"
|
||||||
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
"github.com/karmada-io/karmada/pkg/util/fedinformer/genericmanager"
|
||||||
"github.com/karmada-io/karmada/pkg/util/gclient"
|
"github.com/karmada-io/karmada/pkg/util/gclient"
|
||||||
"github.com/karmada-io/karmada/pkg/util/restmapper"
|
"github.com/karmada-io/karmada/pkg/util/restmapper"
|
||||||
|
@ -103,6 +104,9 @@ func (c *Controller) addAllEventHandlers() {
|
||||||
UpdateFunc: c.updateResourceRegistry,
|
UpdateFunc: c.updateResourceRegistry,
|
||||||
DeleteFunc: c.deleteResourceRegistry,
|
DeleteFunc: c.deleteResourceRegistry,
|
||||||
})
|
})
|
||||||
|
// ignore the error here because the informers haven't been started
|
||||||
|
_ = clusterInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
|
_ = resourceRegistryInformer.SetTransform(fedinformer.StripUnusedFields)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the controller
|
// Start the controller
|
||||||
|
|
Loading…
Reference in New Issue