From db2c311d598e18a71bd3a8e64648ae72821dad54 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 14 Dec 2023 16:50:09 +0100 Subject: [PATCH] bump reva Signed-off-by: jkoberg --- changelog/unreleased/bump-reva.md | 1 + go.mod | 2 +- go.sum | 6 +- .../internal/grpc/services/gateway/gateway.go | 65 +++++++------------ .../grpc/services/gateway/storageprovider.go | 1 - .../services/gateway/storageprovidercache.go | 7 +- .../services/owncloud/ocs/config/config.go | 8 +-- .../handlers/apps/sharing/shares/shares.go | 2 +- .../http/services/owncloud/ocs/ocs.go | 5 +- .../pkg/rhttp/datatx/manager/simple/simple.go | 2 +- .../pkg/rhttp/datatx/manager/spaces/spaces.go | 2 +- .../v2/pkg/rhttp/datatx/manager/tus/tus.go | 3 +- .../cs3org/reva/v2/pkg/storage/cache/cache.go | 58 +++++++++-------- .../reva/v2/pkg/storage/cache/createhome.go | 11 ++-- .../pkg/storage/cache/createpersonalspace.go | 12 ++-- .../reva/v2/pkg/storage/cache/filemetadata.go | 14 ++-- .../reva/v2/pkg/storage/cache/provider.go | 11 ++-- .../cs3org/reva/v2/pkg/storage/cache/stat.go | 11 ++-- .../utils/decomposedfs/decomposedfs.go | 5 +- .../metadata/messagepack_backend.go | 3 +- .../cs3org/reva/v2/pkg/store/options.go | 14 ++++ .../cs3org/reva/v2/pkg/store/store.go | 7 ++ vendor/modules.txt | 2 +- 23 files changed, 121 insertions(+), 131 deletions(-) diff --git a/changelog/unreleased/bump-reva.md b/changelog/unreleased/bump-reva.md index 02ba9ff63..e8fd1390b 100644 --- a/changelog/unreleased/bump-reva.md +++ b/changelog/unreleased/bump-reva.md @@ -4,3 +4,4 @@ Bumps reva version https://github.com/owncloud/ocis/pull/7793 https://github.com/owncloud/ocis/pull/7978 +https://github.com/owncloud/ocis/pull/7979 diff --git a/go.mod b/go.mod index 38981b8c2..11459fd33 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.9.0 github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 - github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f + github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47 github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e diff --git a/go.sum b/go.sum index f769635fb..ad2f34a70 100644 --- a/go.sum +++ b/go.sum @@ -1021,8 +1021,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f h1:AF7fcQ7dfi3sxKLpIFJ8Y2uKJ8umB9K+nFe+3tDa4oA= -github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f/go.mod h1:oX1YtLKGr7jatGk0CpPM4GKbSEIdHhmsQuSAYElnN1U= +github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47 h1:6DfMeFpCXoqlfm/+FJ/mFs8Ul5WCZNlorsbDM9Z/ATE= +github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47/go.mod h1:oX1YtLKGr7jatGk0CpPM4GKbSEIdHhmsQuSAYElnN1U= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -1688,8 +1688,6 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= -github.com/micbar/reva/v2 v2.0.0-20231214215940-ac484c63b45e h1:IsCx3d+WflZgIGFV5TPqGoMRWiygaj11QJvefcUNTUQ= -github.com/micbar/reva/v2 v2.0.0-20231214215940-ac484c63b45e/go.mod h1:oX1YtLKGr7jatGk0CpPM4GKbSEIdHhmsQuSAYElnN1U= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go index 2dc2d44da..b8e6533da 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go @@ -22,7 +22,6 @@ import ( "fmt" "net/url" "strings" - "time" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" "github.com/cs3org/reva/v2/pkg/errtypes" @@ -64,26 +63,14 @@ type config struct { TokenManager string `mapstructure:"token_manager"` // ShareFolder is the location where to create shares in the recipient's storage provider. // FIXME get rid of ShareFolder, there are findByPath calls in the ocmshareporvider.go and usershareprovider.go - ShareFolder string `mapstructure:"share_folder"` - DataTransfersFolder string `mapstructure:"data_transfers_folder"` - TokenManagers map[string]map[string]interface{} `mapstructure:"token_managers"` - AllowedUserAgents map[string][]string `mapstructure:"allowed_user_agents"` // map[path][]user-agent - StatCacheStore string `mapstructure:"stat_cache_store"` - StatCacheNodes []string `mapstructure:"stat_cache_nodes"` - StatCacheDatabase string `mapstructure:"stat_cache_database"` - StatCacheTTL int `mapstructure:"stat_cache_ttl"` - StatCacheSize int `mapstructure:"stat_cache_size"` - CreateHomeCacheStore string `mapstructure:"create_home_cache_store"` - CreateHomeCacheNodes []string `mapstructure:"create_home_cache_nodes"` - CreateHomeCacheDatabase string `mapstructure:"create_home_cache_database"` - CreateHomeCacheTTL int `mapstructure:"create_home_cache_ttl"` - CreateHomeCacheSize int `mapstructure:"create_home_cache_size"` - ProviderCacheStore string `mapstructure:"provider_cache_store"` - ProviderCacheNodes []string `mapstructure:"provider_cache_nodes"` - ProviderCacheDatabase string `mapstructure:"provider_cache_database"` - ProviderCacheTTL int `mapstructure:"provider_cache_ttl"` - ProviderCacheSize int `mapstructure:"provider_cache_size"` - UseCommonSpaceRootShareLogic bool `mapstructure:"use_common_space_root_share_logic"` + ShareFolder string `mapstructure:"share_folder"` + DataTransfersFolder string `mapstructure:"data_transfers_folder"` + TokenManagers map[string]map[string]interface{} `mapstructure:"token_managers"` + AllowedUserAgents map[string][]string `mapstructure:"allowed_user_agents"` // map[path][]user-agent + StatCacheConfig cache.Config `mapstructure:"stat_cache_config"` + CreatePersonalSpaceCacheConfig cache.Config `mapstructure:"create_personal_space_cache_config"` + ProviderCacheConfig cache.Config `mapstructure:"provider_cache_config"` + UseCommonSpaceRootShareLogic bool `mapstructure:"use_common_space_root_share_logic"` } // sets defaults @@ -130,28 +117,28 @@ func (c *config) init() { } // caching needs to be explicitly enabled - if c.StatCacheStore == "" { - c.StatCacheStore = "noop" + if c.StatCacheConfig.Store == "" { + c.StatCacheConfig.Store = "noop" } - if c.StatCacheDatabase == "" { - c.StatCacheDatabase = "reva" + if c.StatCacheConfig.Database == "" { + c.StatCacheConfig.Database = "reva" } - if c.ProviderCacheStore == "" { - c.ProviderCacheStore = "noop" + if c.ProviderCacheConfig.Store == "" { + c.ProviderCacheConfig.Store = "noop" } - if c.ProviderCacheDatabase == "" { - c.ProviderCacheDatabase = "reva" + if c.ProviderCacheConfig.Database == "" { + c.ProviderCacheConfig.Database = "reva" } - if c.CreateHomeCacheStore == "" { - c.CreateHomeCacheStore = "noop" + if c.CreatePersonalSpaceCacheConfig.Store == "" { + c.CreatePersonalSpaceCacheConfig.Store = "noop" } - if c.CreateHomeCacheDatabase == "" { - c.CreateHomeCacheDatabase = "reva" + if c.CreatePersonalSpaceCacheConfig.Database == "" { + c.CreatePersonalSpaceCacheConfig.Database = "reva" } } @@ -161,14 +148,13 @@ type svc struct { tokenmgr token.Manager statCache cache.StatCache providerCache cache.ProviderCache - createHomeCache cache.CreateHomeCache createPersonalSpaceCache cache.CreatePersonalSpaceCache } // New creates a new gateway svc that acts as a proxy for any grpc operation. // The gateway is responsible for high-level controls: rate-limiting, coordination between svcs // like sharing and storage acls, asynchronous transactions, ... -func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) { +func New(m map[string]interface{}, _ *grpc.Server) (rgrpc.Service, error) { c, err := parseConfig(m) if err != nil { return nil, err @@ -191,10 +177,9 @@ func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) { c: c, dataGatewayURL: *u, tokenmgr: tokenManager, - statCache: cache.GetStatCache(c.StatCacheStore, c.StatCacheNodes, c.StatCacheDatabase, "stat", time.Duration(c.StatCacheTTL)*time.Second, c.StatCacheSize), - providerCache: cache.GetProviderCache(c.ProviderCacheStore, c.ProviderCacheNodes, c.ProviderCacheDatabase, "provider", time.Duration(c.ProviderCacheTTL)*time.Second, c.ProviderCacheSize), - createHomeCache: cache.GetCreateHomeCache(c.CreateHomeCacheStore, c.CreateHomeCacheNodes, c.CreateHomeCacheDatabase, "createHome", time.Duration(c.CreateHomeCacheTTL)*time.Second, c.CreateHomeCacheSize), - createPersonalSpaceCache: cache.GetCreatePersonalSpaceCache(c.CreateHomeCacheStore, c.CreateHomeCacheNodes, c.CreateHomeCacheDatabase, "createPersonalSpace", time.Duration(c.CreateHomeCacheTTL)*time.Second, c.CreateHomeCacheSize), + statCache: cache.GetStatCache(c.StatCacheConfig), + providerCache: cache.GetProviderCache(c.ProviderCacheConfig), + createPersonalSpaceCache: cache.GetCreatePersonalSpaceCache(c.CreatePersonalSpaceCacheConfig), } return s, nil @@ -207,7 +192,7 @@ func (s *svc) Register(ss *grpc.Server) { func (s *svc) Close() error { s.statCache.Close() s.providerCache.Close() - s.createHomeCache.Close() + s.createPersonalSpaceCache.Close() return nil } diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovider.go index a4ad2af39..5347f4bac 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovider.go @@ -1107,7 +1107,6 @@ func (s *svc) getStorageProviderClient(_ context.Context, p *registry.ProviderIn return &cachedAPIClient{ c: c, statCache: s.statCache, - createHomeCache: s.createHomeCache, createPersonalSpaceCache: s.createPersonalSpaceCache, }, nil } diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovidercache.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovidercache.go index 806018d64..8dd5d720b 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovidercache.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/storageprovidercache.go @@ -85,7 +85,6 @@ func (c *cachedRegistryClient) GetHome(ctx context.Context, in *registry.GetHome type cachedAPIClient struct { c provider.ProviderAPIClient statCache cache.StatCache - createHomeCache cache.CreateHomeCache createPersonalSpaceCache cache.CreatePersonalSpaceCache } @@ -121,10 +120,10 @@ func (c *cachedAPIClient) Stat(ctx context.Context, in *provider.StatRequest, op // CreateHome caches calls to CreateHome locally - anyways they only need to be called once per user func (c *cachedAPIClient) CreateHome(ctx context.Context, in *provider.CreateHomeRequest, opts ...grpc.CallOption) (*provider.CreateHomeResponse, error) { - key := c.createHomeCache.GetKey(ctxpkg.ContextMustGetUser(ctx).GetId()) + key := c.createPersonalSpaceCache.GetKey(ctxpkg.ContextMustGetUser(ctx).GetId()) if key != "" { s := &provider.CreateHomeResponse{} - if err := c.createHomeCache.PullFromCache(key, s); err == nil { + if err := c.createPersonalSpaceCache.PullFromCache(key, s); err == nil { return s, nil } } @@ -137,7 +136,7 @@ func (c *cachedAPIClient) CreateHome(ctx context.Context, in *provider.CreateHom case key == "": return resp, nil default: - return resp, c.createHomeCache.PushToCache(key, resp) + return resp, c.createPersonalSpaceCache.PushToCache(key, resp) } } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/config/config.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/config/config.go index 09c5baf43..554a9eeb3 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/config/config.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/config/config.go @@ -21,6 +21,7 @@ package config import ( "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data" "github.com/cs3org/reva/v2/pkg/sharedconf" + "github.com/cs3org/reva/v2/pkg/storage/cache" ) // Config holds the config options that need to be passed down to all ocs handlers @@ -37,12 +38,7 @@ type Config struct { AdditionalInfoAttribute string `mapstructure:"additional_info_attribute"` CacheWarmupDriver string `mapstructure:"cache_warmup_driver"` CacheWarmupDrivers map[string]map[string]interface{} `mapstructure:"cache_warmup_drivers"` - StatCacheStore string `mapstructure:"stat_cache_store"` - StatCacheNodes []string `mapstructure:"stat_cache_nodes"` - StatCacheDatabase string `mapstructure:"stat_cache_database"` - StatCacheTable string `mapstructure:"stat_cache_table"` - StatCacheTTL int `mapstructure:"stat_cache_ttl"` - StatCacheSize int `mapstructure:"stat_cache_size"` + StatCacheConfig cache.Config `mapstructure:"stat_cache_config"` UserIdentifierCacheTTL int `mapstructure:"user_identifier_cache_ttl"` MachineAuthAPIKey string `mapstructure:"machine_auth_apikey"` SkipUpdatingExistingSharesMountpoints bool `mapstructure:"skip_updating_existing_shares_mountpoint"` diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index a2552b69e..22265a857 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -150,7 +150,7 @@ func (h *Handler) Init(c *config.Config) error { h.publicPasswordEnforced = publicPwdEnforced(c) h.passwordValidator = passwordPolicies(c) - h.statCache = cache.GetStatCache(c.StatCacheStore, c.StatCacheNodes, c.StatCacheDatabase, "stat", time.Duration(c.StatCacheTTL)*time.Second, c.StatCacheSize) + h.statCache = cache.GetStatCache(c.StatCacheConfig) if c.CacheWarmupDriver != "" { cwm, err := getCacheWarmupManager(c) if err != nil { diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go index 2982e4dfa..c71da5d9b 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/ocs.go @@ -20,7 +20,6 @@ package ocs import ( "net/http" - "time" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/sharees" @@ -67,9 +66,9 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error) return nil, err } - if conf.CacheWarmupDriver == "first-request" && conf.StatCacheStore != "noop" { + if conf.CacheWarmupDriver == "first-request" && conf.StatCacheConfig.Store != "noop" { s.warmupCacheTracker = ttlcache.NewCache() - _ = s.warmupCacheTracker.SetTTL(time.Second * time.Duration(conf.StatCacheTTL)) + _ = s.warmupCacheTracker.SetTTL(conf.StatCacheConfig.TTL) } return s, nil diff --git a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/simple/simple.go b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/simple/simple.go index b5ac5b924..a89ce71ec 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/simple/simple.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/simple/simple.go @@ -70,7 +70,7 @@ func New(m map[string]interface{}, publisher events.Publisher) (datatx.DataTX, e return &manager{ conf: c, publisher: publisher, - statCache: cache.GetStatCache(c.Store, c.Nodes, c.Database, c.Table, time.Duration(c.TTL)*time.Second, c.Size), + statCache: cache.GetStatCache(*c), }, nil } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/spaces/spaces.go b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/spaces/spaces.go index 6e2ef0370..d39b12baa 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/spaces/spaces.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/spaces/spaces.go @@ -72,7 +72,7 @@ func New(m map[string]interface{}, publisher events.Publisher) (datatx.DataTX, e return &manager{ conf: c, publisher: publisher, - statCache: cache.GetStatCache(c.Store, c.Nodes, c.Database, c.Table, time.Duration(c.TTL)*time.Second, c.Size), + statCache: cache.GetStatCache(*c), }, nil } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/tus/tus.go b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/tus/tus.go index a46bd1773..fbad5e5bb 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/tus/tus.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/manager/tus/tus.go @@ -23,7 +23,6 @@ import ( "log" "net/http" "path" - "time" "github.com/pkg/errors" tusd "github.com/tus/tusd/pkg/handler" @@ -71,7 +70,7 @@ func New(m map[string]interface{}, publisher events.Publisher) (datatx.DataTX, e return &manager{ conf: c, publisher: publisher, - statCache: cache.GetStatCache(c.Store, c.Nodes, c.Database, c.Table, time.Duration(c.TTL)*time.Second, c.Size), + statCache: cache.GetStatCache(*c), }, nil } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go index af4b0ffdc..c02d24624 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/cache.go @@ -44,12 +44,13 @@ var ( // Config contains the configuring for a cache type Config struct { - Store string `mapstructure:"cache_store"` - Nodes []string `mapstructure:"cache_nodes"` - Database string `mapstructure:"cache_database"` - Table string `mapstructure:"cache_table"` - TTL int `mapstructure:"cache_ttl"` - Size int `mapstructure:"cache_size"` + Store string `mapstructure:"cache_store"` + Nodes []string `mapstructure:"cache_nodes"` + Database string `mapstructure:"cache_database"` + Table string `mapstructure:"cache_table"` + TTL time.Duration `mapstructure:"cache_ttl"` + Size int `mapstructure:"cache_size"` + DisablePersistence bool `mapstructure:"cache_disable_persistence"` } // Cache handles key value operations on caches @@ -100,65 +101,65 @@ type FileMetadataCache interface { // GetStatCache will return an existing StatCache for the given store, nodes, database and table // If it does not exist yet it will be created, different TTLs are ignored -func GetStatCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) StatCache { +func GetStatCache(cfg Config) StatCache { mutex.Lock() defer mutex.Unlock() - key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":") + key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":") if statCaches[key] == nil { - statCaches[key] = NewStatCache(cacheStore, cacheNodes, database, table, ttl, size) + statCaches[key] = NewStatCache(cfg) } return statCaches[key] } // GetProviderCache will return an existing ProviderCache for the given store, nodes, database and table // If it does not exist yet it will be created, different TTLs are ignored -func GetProviderCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) ProviderCache { +func GetProviderCache(cfg Config) ProviderCache { mutex.Lock() defer mutex.Unlock() - key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":") + key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":") if providerCaches[key] == nil { - providerCaches[key] = NewProviderCache(cacheStore, cacheNodes, database, table, ttl, size) + providerCaches[key] = NewProviderCache(cfg) } return providerCaches[key] } // GetCreateHomeCache will return an existing CreateHomeCache for the given store, nodes, database and table // If it does not exist yet it will be created, different TTLs are ignored -func GetCreateHomeCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) CreateHomeCache { +func GetCreateHomeCache(cfg Config) CreateHomeCache { mutex.Lock() defer mutex.Unlock() - key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":") + key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":") if createHomeCaches[key] == nil { - createHomeCaches[key] = NewCreateHomeCache(cacheStore, cacheNodes, database, table, ttl, size) + createHomeCaches[key] = NewCreateHomeCache(cfg) } return createHomeCaches[key] } // GetCreatePersonalSpaceCache will return an existing CreatePersonalSpaceCache for the given store, nodes, database and table // If it does not exist yet it will be created, different TTLs are ignored -func GetCreatePersonalSpaceCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) CreatePersonalSpaceCache { +func GetCreatePersonalSpaceCache(cfg Config) CreatePersonalSpaceCache { mutex.Lock() defer mutex.Unlock() - key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":") + key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":") if createPersonalSpaceCaches[key] == nil { - createPersonalSpaceCaches[key] = NewCreatePersonalSpaceCache(cacheStore, cacheNodes, database, table, ttl, size) + createPersonalSpaceCaches[key] = NewCreatePersonalSpaceCache(cfg) } return createPersonalSpaceCaches[key] } // GetFileMetadataCache will return an existing GetFileMetadataCache for the given store, nodes, database and table // If it does not exist yet it will be created, different TTLs are ignored -func GetFileMetadataCache(cacheStore string, cacheNodes []string, database, table string, ttl time.Duration, size int) FileMetadataCache { +func GetFileMetadataCache(cfg Config) FileMetadataCache { mutex.Lock() defer mutex.Unlock() - key := strings.Join(append(append([]string{cacheStore}, cacheNodes...), database, table), ":") + key := strings.Join(append(append([]string{cfg.Store}, cfg.Nodes...), cfg.Database, cfg.Table), ":") if fileMetadataCaches[key] == nil { - fileMetadataCaches[key] = NewFileMetadataCache(cacheStore, cacheNodes, database, table, ttl, size) + fileMetadataCaches[key] = NewFileMetadataCache(cfg) } return fileMetadataCaches[key] } @@ -230,13 +231,14 @@ func (cache cacheStore) Close() error { return cache.s.Close() } -func getStore(storeType string, nodes []string, database, table string, ttl time.Duration, size int) microstore.Store { +func getStore(cfg Config) microstore.Store { return store.Create( - store.Store(storeType), - microstore.Nodes(nodes...), - microstore.Database(database), - microstore.Table(table), - store.TTL(ttl), - store.Size(size), + store.Store(cfg.Store), + microstore.Nodes(cfg.Nodes...), + microstore.Database(cfg.Database), + microstore.Table(cfg.Table), + store.TTL(cfg.TTL), + store.Size(cfg.Size), + store.DisablePersistence(cfg.DisablePersistence), ) } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createhome.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createhome.go index 8a39c68a5..3b3c67835 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createhome.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createhome.go @@ -20,7 +20,6 @@ package cache import ( "strings" - "time" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -32,12 +31,12 @@ type createHomeCache struct { } // NewCreateHomeCache creates a new CreateHomeCache -func NewCreateHomeCache(store string, nodes []string, database, table string, ttl time.Duration, size int) CreateHomeCache { +func NewCreateHomeCache(cfg Config) CreateHomeCache { c := &createHomeCache{} - c.s = getStore(store, nodes, database, table, ttl, size) - c.database = database - c.table = table - c.ttl = ttl + c.s = getStore(cfg) + c.database = cfg.Database + c.table = cfg.Table + c.ttl = cfg.TTL return c } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createpersonalspace.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createpersonalspace.go index fa6f9d11e..b7422b504 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createpersonalspace.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/createpersonalspace.go @@ -19,8 +19,6 @@ package cache import ( - "time" - userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" ) @@ -30,12 +28,12 @@ type createPersonalSpaceCache struct { } // NewCreatePersonalSpaceCache creates a new CreatePersonalSpaceCache -func NewCreatePersonalSpaceCache(store string, nodes []string, database, table string, ttl time.Duration, size int) CreatePersonalSpaceCache { +func NewCreatePersonalSpaceCache(cfg Config) CreatePersonalSpaceCache { c := &createPersonalSpaceCache{} - c.s = getStore(store, nodes, database, table, ttl, size) - c.database = database - c.table = table - c.ttl = ttl + c.s = getStore(cfg) + c.database = cfg.Database + c.table = cfg.Table + c.ttl = cfg.TTL return c } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/filemetadata.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/filemetadata.go index 41053b4f2..987e451df 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/filemetadata.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/filemetadata.go @@ -18,21 +18,17 @@ package cache -import ( - "time" -) - type fileMetadataCache struct { cacheStore } // NewFileMetadataCache creates a new FileMetadataCache -func NewFileMetadataCache(store string, nodes []string, database, table string, ttl time.Duration, size int) FileMetadataCache { +func NewFileMetadataCache(cfg Config) FileMetadataCache { c := &fileMetadataCache{} - c.s = getStore(store, nodes, database, table, ttl, size) - c.database = database - c.table = table - c.ttl = ttl + c.s = getStore(cfg) + c.database = cfg.Database + c.table = cfg.Table + c.ttl = cfg.TTL return c } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/provider.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/provider.go index 23b8a3f82..306498c10 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/provider.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/provider.go @@ -20,7 +20,6 @@ package cache import ( "sync" - "time" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -33,12 +32,12 @@ type providerCache struct { } // NewProviderCache creates a new ProviderCache -func NewProviderCache(store string, nodes []string, database, table string, ttl time.Duration, size int) ProviderCache { +func NewProviderCache(cfg Config) ProviderCache { c := &providerCache{} - c.s = getStore(store, nodes, database, table, ttl, size) - c.database = database - c.table = table - c.ttl = ttl + c.s = getStore(cfg) + c.database = cfg.Database + c.table = cfg.Table + c.ttl = cfg.TTL return c } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/stat.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/stat.go index bb39cf939..19045e362 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/stat.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/cache/stat.go @@ -22,7 +22,6 @@ import ( "context" "strings" "sync" - "time" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -40,12 +39,12 @@ func init() { } // NewStatCache creates a new StatCache -func NewStatCache(store string, nodes []string, database, table string, ttl time.Duration, size int) StatCache { +func NewStatCache(cfg Config) StatCache { c := statCache{} - c.s = getStore(store, nodes, database, table, ttl, size) - c.database = database - c.table = table - c.ttl = ttl + c.s = getStore(cfg) + c.database = cfg.Database + c.table = cfg.Table + c.ttl = cfg.TTL return &c } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go index 5c341c735..60662ee81 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go @@ -138,11 +138,12 @@ func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) ( tp := tree.New(lu, bs, o, store.Create( store.Store(o.IDCache.Store), - store.TTL(time.Duration(o.IDCache.TTL)*time.Second), + store.TTL(o.IDCache.TTL), store.Size(o.IDCache.Size), microstore.Nodes(o.IDCache.Nodes...), microstore.Database(o.IDCache.Database), microstore.Table(o.IDCache.Table), + store.DisablePersistence(o.IDCache.DisablePersistence), )) permissionsSelector, err := pool.PermissionsSelector(o.PermissionsSVC, pool.WithTLSMode(o.PermTLSMode)) @@ -203,7 +204,7 @@ func New(o *options.Options, lu *lookup.Lookup, p Permissions, tp Tree, es event p: p, chunkHandler: chunking.NewChunkHandler(filepath.Join(o.Root, "uploads")), stream: es, - cache: cache.GetStatCache(o.StatCache.Store, o.StatCache.Nodes, o.StatCache.Database, "stat", time.Duration(o.StatCache.TTL)*time.Second, o.StatCache.Size), + cache: cache.GetStatCache(o.StatCache), UserCache: ttlcache.NewCache(), userSpaceIndex: userSpaceIndex, groupSpaceIndex: groupSpaceIndex, 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 92caf0cf5..ab7c7e8fd 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 @@ -27,7 +27,6 @@ import ( "path/filepath" "strconv" "strings" - "time" "github.com/cs3org/reva/v2/pkg/storage/cache" "github.com/google/renameio/v2" @@ -53,7 +52,7 @@ type readWriteCloseSeekTruncater interface { func NewMessagePackBackend(rootPath string, o cache.Config) MessagePackBackend { return MessagePackBackend{ rootPath: filepath.Clean(rootPath), - metaCache: cache.GetFileMetadataCache(o.Store, o.Nodes, o.Database, "filemetadata:", time.Duration(o.TTL)*time.Second, o.Size), + metaCache: cache.GetFileMetadataCache(o), } } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/store/options.go b/vendor/github.com/cs3org/reva/v2/pkg/store/options.go index 5866d6f09..c4e177e54 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/store/options.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/store/options.go @@ -75,3 +75,17 @@ func TTL(val time.Duration) store.Option { o.Context = context.WithValue(o.Context, ttlContextKey{}, val) } } + +type disablePersistanceContextKey struct{} + +// DisablePersistence disables the persistence of the store by instructing it to use memory only. +// Only supported by the `natsjs` and `natsjskv` implementations. +func DisablePersistence(val bool) store.Option { + return func(o *store.Options) { + if o.Context == nil { + o.Context = context.Background() + } + + o.Context = context.WithValue(o.Context, disablePersistanceContextKey{}, val) + } +} diff --git a/vendor/github.com/cs3org/reva/v2/pkg/store/store.go b/vendor/github.com/cs3org/reva/v2/pkg/store/store.go index c3f66d376..67ef00dd2 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/store/store.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/store/store.go @@ -119,6 +119,9 @@ func Create(opts ...microstore.Option) microstore.Store { return *ocMemStore case TypeNatsJS: ttl, _ := options.Context.Value(ttlContextKey{}).(time.Duration) + if mem, _ := options.Context.Value(disablePersistanceContextKey{}).(bool); mem { + opts = append(opts, natsjs.DefaultMemory()) + } // TODO nats needs a DefaultTTL option as it does not support per Write TTL ... // FIXME nats has restrictions on the key, we cannot use slashes AFAICT // host, port, clusterid @@ -132,6 +135,10 @@ func Create(opts ...microstore.Option) microstore.Store { case TypeNatsJSKV: // NOTE: nats needs a DefaultTTL option as it does not support per Write TTL ... ttl, _ := options.Context.Value(ttlContextKey{}).(time.Duration) + if mem, _ := options.Context.Value(disablePersistanceContextKey{}).(bool); mem { + opts = append(opts, natsjskv.DefaultMemory()) + } + natsOptions := nats.GetDefaultOptions() natsOptions.Name = "TODO" // we can pass in the service name to allow identifying the client, but that requires adding a custom context option return natsjskv.NewStore( diff --git a/vendor/modules.txt b/vendor/modules.txt index 30186125d..e43d9ef67 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -362,7 +362,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.17.1-0.20231215110403-2f85376a4d3f +# github.com/cs3org/reva/v2 v2.17.1-0.20231215113433-48c0ea55bf47 ## explicit; go 1.21 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime