diff --git a/.drone.star b/.drone.star index faa2eb9643..0701401219 100644 --- a/.drone.star +++ b/.drone.star @@ -1919,6 +1919,9 @@ def ocisServer(storage, accounts_hash_difficulty = 4, volumes = [], depends_on = "OCIS_EVENTS_ENABLE_TLS": False, "MICRO_REGISTRY": "natsjs", "MICRO_REGISTRY_ADDRESS": "127.0.0.1:9233", + "OCIS_CACHE_STORE": "nats-js-kv", + "OCIS_CACHE_STORE_NODES": "127.0.0.1:9233", + "OCIS_CACHE_DATABASE": "cache", } if deploy_type == "": diff --git a/changelog/unreleased/fix-natsjs-cache.md b/changelog/unreleased/fix-natsjs-cache.md new file mode 100644 index 0000000000..002867d024 --- /dev/null +++ b/changelog/unreleased/fix-natsjs-cache.md @@ -0,0 +1,5 @@ +Bugfix: Fix natsjs cache + +The nats-js cache was not working. It paniced and wrote a lot of error logs. Both is fixed now. + +https://github.com/owncloud/ocis/pull/7790 diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 5c74c6e0f6..c1ef417473 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -64,6 +64,8 @@ import ( var ( // runset keeps track of which services to start supervised. runset map[string]struct{} + // time to wait after starting the preliminary services + _preliminaryDelay = 6 * time.Second // time to wait between starting service groups (preliminary, main, delayed) _startDelay = 2 * time.Second ) @@ -413,8 +415,8 @@ func Start(o ...Option) error { // trap will block on halt channel for interruptions. go trap(s, halt) - // grace period for supervisor to get up - time.Sleep(_startDelay) + // grace period for preliminary services to get up + time.Sleep(_preliminaryDelay) // schedule services that we are sure don't have interdependencies. scheduleServiceTokens(s, s.ServicesRegistry) diff --git a/services/gateway/pkg/config/config.go b/services/gateway/pkg/config/config.go index 73c6a01ee4..f30bb8b364 100644 --- a/services/gateway/pkg/config/config.go +++ b/services/gateway/pkg/config/config.go @@ -85,7 +85,7 @@ type StorageRegistry struct { // Cache holds cache config type Cache struct { - StatCacheStore string `yaml:"stat_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_STAT_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."` + StatCacheStore string // TODO: enable configuring this again // `yaml:"stat_cache_store" env:"OCIS_CACHE_STORE;GATEWAY_STAT_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."` StatCacheNodes []string `yaml:"stat_cache_nodes" env:"OCIS_CACHE_STORE_NODES;GATEWAY_STAT_CACHE_STORE_NODES" desc:"A 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. See the Environment Variable Types description for more details."` StatCacheDatabase string `yaml:"stat_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."` StatCacheTTL time.Duration `yaml:"stat_cache_ttl" env:"OCIS_CACHE_TTL;GATEWAY_STAT_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details."` diff --git a/services/storage-users/pkg/config/defaults/defaultconfig.go b/services/storage-users/pkg/config/defaults/defaultconfig.go index 1bb34eab57..1268b20cf5 100644 --- a/services/storage-users/pkg/config/defaults/defaultconfig.go +++ b/services/storage-users/pkg/config/defaults/defaultconfig.go @@ -103,6 +103,11 @@ func DefaultConfig() *config.Config { Database: "ocis", TTL: 24 * 60 * time.Second, }, + IDCache: config.IDCache{ + Store: "nats-js-kv", + Database: "ocis", + TTL: 24 * 60 * time.Second, + }, Tasks: config.Tasks{ PurgeTrashBin: config.PurgeTrashBin{ ProjectDeleteBefore: 30 * 24 * time.Hour, diff --git a/tests/ociswrapper/ocis/ocis.go b/tests/ociswrapper/ocis/ocis.go index c9762b6fd0..815b8c1abd 100644 --- a/tests/ociswrapper/ocis/ocis.go +++ b/tests/ociswrapper/ocis/ocis.go @@ -128,7 +128,7 @@ func WaitForConnection() bool { Transport: transport, } - req, _ := http.NewRequest("GET", config.Get("url")+"/graph/v1.0/users/"+config.Get("adminUsername"), nil) + req, _ := http.NewRequest("GET", config.Get("url")+"/graph/v1.0/me/drives", nil) req.SetBasicAuth(config.Get("adminUsername"), config.Get("adminPassword")) timeout := time.After(timeoutValue) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata/messagepack_backend.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata/messagepack_backend.go index 92caf0cf52..d0c491ec78 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata/messagepack_backend.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata/messagepack_backend.go @@ -275,9 +275,7 @@ func (MessagePackBackend) IsMetaFile(path string) bool { // Purge purges the data of a given path func (b MessagePackBackend) Purge(path string) error { - if err := b.metaCache.RemoveMetadata(b.cacheKey(path)); err != nil { - return err - } + _ = b.metaCache.RemoveMetadata(b.cacheKey(path)) return os.Remove(b.MetadataPath(path)) } @@ -291,10 +289,7 @@ func (b MessagePackBackend) Rename(oldPath, newPath string) error { return err } } - err = b.metaCache.RemoveMetadata(b.cacheKey(oldPath)) - if err != nil { - return err - } + _ = b.metaCache.RemoveMetadata(b.cacheKey(oldPath)) return os.Rename(b.MetadataPath(oldPath), b.MetadataPath(newPath)) }