Git Product home page Git Product logo

Comments (9)

fgiloux avatar fgiloux commented on September 27, 2024 2

@ncdc thank you for the pointer and sorry for the delay.
Adding something like this seems to work:

func ClusterAwareBuilderWithOptions(options cache.Options) cache.NewCacheFunc {
	return func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
		if options.Scheme == nil {
			options.Scheme = opts.Scheme
		}
		if options.Mapper == nil {
			options.Mapper = opts.Mapper
		}
		if options.Resync == nil {
			options.Resync = opts.Resync
		}
		if options.Namespace == "" {
			options.Namespace = opts.Namespace
		}
		if opts.Resync == nil {
			opts.Resync = options.Resync
		}

		return kcp.NewClusterAwareCache(config, options)
	}
}

I would think it belongs to the wrapper. What do you think?
cc @varshaprasad96

from controller-runtime.

ncdc avatar ncdc commented on September 27, 2024

If you're managing the NewCache function, you need to make sure it does this:

func NewClusterAwareCache(config *rest.Config, opts cache.Options) (cache.Cache, error) {
c := rest.CopyConfig(config)
c.Host += "/clusters/*"
opts.NewInformerFunc = informers.NewSharedIndexInformer
opts.Indexers = k8scache.Indexers{
kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc,
kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc,
}
return cache.New(c, opts)
}

from controller-runtime.

ncdc avatar ncdc commented on September 27, 2024

@stevekuznetsov

from controller-runtime.

fgiloux avatar fgiloux commented on September 27, 2024

Note: "seems to work" except that there is no label conversion for APIBinding so that I cannot filter through spec.reference.workspace.exportName and spec.reference.workspace.path but it would work for Pods for instance. Obviously the fact that not many resources support the mechanism significantly diminishes its value

from controller-runtime.

stevekuznetsov avatar stevekuznetsov commented on September 27, 2024

Yeah, field selectors are very hard-coded and limited :|

from controller-runtime.

stevekuznetsov avatar stevekuznetsov commented on September 27, 2024

Could you use an index here?

from controller-runtime.

fgiloux avatar fgiloux commented on September 27, 2024

Could you use an index here?

I am not sure to follow. My understanding is that indexes help with retrieving resources from cache not avoiding them to get cached. Please let me know what I am missing. My original intent was not to cache the resources that I don't need to save some memory. As a workaround I am filtering the event and add unnecessary apibindings into the cache. As I am not expecting a huge amount of apibindings it is not a major concern for me.

An open question is: do we see value in making a cluster aware version of controller-runtime BuilderWithOptions?
As you stated for field selectors it is not granted but possibly for the other configurations? I am happy to create a PR if the answer is yes.

from controller-runtime.

stevekuznetsov avatar stevekuznetsov commented on September 27, 2024

Please let me know what I am missing.

Sorry, I didn't realize your intent was to make your cache size smaller in memory. The index won't help there.

do we see value in making a cluster aware version of controller-runtime BuilderWithOptions?

I swear we had a PR open to do this .. yes, I think it's a good idea ish.

from controller-runtime.

fgiloux avatar fgiloux commented on September 27, 2024

ack. I will look at that tomorrow.

from controller-runtime.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.