argo-cd icon indicating copy to clipboard operation
argo-cd copied to clipboard

[ArgoCD] Cache key enhancement

Open rajarshipal-lab opened this issue 2 years ago • 5 comments

Summary

Argocd is using cache key as "...", which may be modified to "%s...", where %s by default is "" but can be given any value "abc" through environmental variable on-demand after which the key becomes "abc..."

Motivation

  • Multiple instances of argocd may use centralized cache instance which can be opted by end user on-demand...
  • Assuming 500 argocd instances with 3 redis pods each are running across organizations in an enterprise, where total pod count becomes 1500 for only redis, also can't ensure usage of all those instances are to the fullest, may be a dedicated cluster of redis made with 3,5, etc instances of redis would benefit...

Proposal

Cache struct in cache.go -> can have another prefix string field which get data through os.env or similar to how REDIS_PASSWORD is getting injected as shown below

type Cache struct {
	client CacheClient
	prefix string `default:""`
}

Other changes would be in package named reposerver/cache.go, server/cache.go, util/cache.go, util/cache/appstate.go where cache key is getting generated like in util/cache/go currently its

func (c *Cache) GetItem(key string, item interface{}) error {
	if item == nil {
		return fmt.Errorf("cannot get item into a nil for key %s", key)
	}
	key = fmt.Sprintf("%s|%s", key, common.CacheVersion)
	return c.client.Get(key, item)
}

and it becomes

func (c *Cache) GetItem(key string, item interface{}) error {
	if item == nil {
		return fmt.Errorf("cannot get item into a nil for key %s", key)
	}
	key = fmt.Sprintf("%s%s|%s", c.GetPrefix(), key, common.CacheVersion)
	return c.client.Get(key, item)
}

rajarshipal-lab avatar Mar 23 '23 17:03 rajarshipal-lab

@crenshaw-dev Can you review the proposal! As we are willing to contribute to this issue as it would benefit us in the long run!

rajarshipal-lab avatar Apr 17 '23 05:04 rajarshipal-lab

@crenshaw-dev Can you please review the proposal!

rajarshipal-lab avatar Sep 18 '23 13:09 rajarshipal-lab

@rajarshipal-lab I like the idea. My only question would be whether there's some existing "instance name" config item we can reuse for this prefix. There are other use cases which require disambiguation among Argo CD instances. Maybe we can reuse something that already exists. I've added this to Thursday's contributor meeting agenda.

crenshaw-dev avatar Sep 18 '23 16:09 crenshaw-dev

Hi everyone

I was researching about if this could be possible. But at contributor meeting agenda says that september 21th this topic would be discussed. But I couldn't find the recording of it and any more information related to this, but the issue still open. Could someone share more info, please?

Thanks in advance

image

CarlosBrunoE avatar Dec 05 '23 01:12 CarlosBrunoE

Any update on this?

rotemjac avatar Oct 11 '24 05:10 rotemjac

Any update on this?

@rotemjac If you are willing to proceed with the implementation, please proceed, as we have figured out some workaround on our side

rajarshipal-lab avatar Feb 11 '25 12:02 rajarshipal-lab

we have figured out some workaround on our side

Could you share your workaround? I am very interested and looking to integrate this

username-here10 avatar Jul 20 '25 11:07 username-here10