Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings: Move cache implementation go-micro/store #6264

Merged
merged 3 commits into from
May 12, 2023

Conversation

rhafer
Copy link
Contributor

@rhafer rhafer commented May 9, 2023

This moves the settings cache to use a go-micro/store based caching implementation, similar to what we're using in many other services meanwhile.

This also switches to a different fork of go-micro/v4/store/redis as we need this fix: micro/plugins#110 for making the cacheinvalidation (https://github.com/owncloud/ocis/pull/6264/files#diff-9426c2b35f285118038505973e5852f93b8a31c9240420ebfd2057d3a3aaa9d9R162) work.

@update-docs
Copy link

update-docs bot commented May 9, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@rhafer rhafer marked this pull request as ready for review May 10, 2023 13:21
@rhafer rhafer requested review from kulmann and lookacat as code owners May 10, 2023 13:21
@rhafer rhafer requested review from dragonchaser and kobergj May 10, 2023 13:21
@rhafer rhafer changed the title WIP: settings: Move cache implementation go-micro/store settings: Move cache implementation go-micro/store May 10, 2023
@rhafer rhafer removed request for lookacat and kulmann May 10, 2023 14:59
rhafer added 3 commits May 12, 2023 09:17
Share the same instance between the HTTP and the GRPC service. This is
in preparation for moving the cache of the metadata storage backend to a
go-micro/store based implementation. By sharing the same service instance in
the HTTP and GRPC services we can avoid the usage of global variables for the
caches, which will make the move to the go-micro/store implementation simpler.
The previous implementation was using an unlimited TTL which would cause
problems in scale out deployments where multiple instances of the settings
service are running.

Fixes: owncloud#5067
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
12.6% 12.6% Duplication

@wkloucek
Copy link
Contributor

@micbar This would be interesting for a current project, that you also know. Because if a user would be unassigned from the "local admin" role, without this fix, the user would still stay a local admin until we restart the settings services. From what @rhafer told me, this needs no deployment changes.

Copy link
Collaborator

@kobergj kobergj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

envvar should be renamed imho. rest looks good 👍

type Cache struct {
Store string `yaml:"store" env:"OCIS_CACHE_STORE;SETTINGS_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'ocmem', 'etcd', 'redis', 'redis-sentinel', 'nats-js', 'noop'. See the text description for details."`
Nodes []string `yaml:"addresses" env:"OCIS_CACHE_STORE_NODES;SETTINGS_CACHE_STORE_NODES" desc:"A comma separated list of nodes to access the configured store. This has no effect when 'memory' or 'ocmem' stores are configured. Note that the behaviour how nodes are used is dependent on the library of the configured store."`
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
Database string `yaml:"database" env:"SETTINGS_CACHE_DATABASE" desc:"The database name the configured store should use."`

afaik there is no global var for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kobergj I was also wondering. But frontend, gateway, proxy, storage-system and storage-users all use OCIS_CACHE_DATABASE (without any local override).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny. userlog, eventhistory, graph and postprocessing all use local Envvars without global override 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, those are STORE_DATABASE settings as oposed to CACHE_DATABASE. Well except GRAPH_CACHE_STORE_DATABASE, which .... 🤔 🤯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the env vars try to distinguish between stores (used for persisting data, currently eventhistory and userlog iirc) and caches (used for volatile caches just used to improve performance). Caches also use stores to store their data, though, which is why we have these CACHE_STORE and CACHE_STORE_NODES vars.

Where it gets inconsisten is with the CACHE_STORE_DATABASE and GRAPH_CACHE_STORE_DATABASE, they should be CACHE_DATABASE and GRAPH_CACHE_DATABASE to be consistent with the other caches imo :|

That being said the whole database configuration is pretty annoying anyway because not all stores will consider it which can potentially lead to clashes between services with shared stores 🙈

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for me to keep as is for now

@rhafer rhafer merged commit 3995084 into owncloud:master May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants