From d6467929d7c515974c7904e133e1c27da1ad89d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 10 Jan 2022 09:33:28 +0000 Subject: [PATCH] fix registry caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/fix-registry-caching.md | 5 +++++ internal/grpc/services/gateway/storageprovidercache.go | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/fix-registry-caching.md diff --git a/changelog/unreleased/fix-registry-caching.md b/changelog/unreleased/fix-registry-caching.md new file mode 100644 index 00000000000..e8e89fc7c36 --- /dev/null +++ b/changelog/unreleased/fix-registry-caching.md @@ -0,0 +1,5 @@ +Bugfix: fix registry caching + +We now cache space lookups per user. + +https://github.com/cs3org/reva/pull/2427 \ No newline at end of file diff --git a/internal/grpc/services/gateway/storageprovidercache.go b/internal/grpc/services/gateway/storageprovidercache.go index ad66f557528..4df829d4a09 100644 --- a/internal/grpc/services/gateway/storageprovidercache.go +++ b/internal/grpc/services/gateway/storageprovidercache.go @@ -164,7 +164,11 @@ type cachedRegistryClient struct { func (c *cachedRegistryClient) ListStorageProviders(ctx context.Context, in *registry.ListStorageProvidersRequest, opts ...grpc.CallOption) (*registry.ListStorageProvidersResponse, error) { cache := c.caches[listproviders] - key := sdk.DecodeOpaqueMap(in.Opaque)["storage_id"] + user := ctxpkg.ContextMustGetUser(ctx) + + storageID := sdk.DecodeOpaqueMap(in.Opaque)["storage_id"] + + key := user.GetId().GetOpaqueId() + storageID if key != "" { s := ®istry.ListStorageProvidersResponse{} if err := pullFromCache(cache, key, s); err == nil { @@ -176,9 +180,9 @@ func (c *cachedRegistryClient) ListStorageProviders(ctx context.Context, in *reg switch { case err != nil: return nil, err - case resp.Status.Code != rpc.Code_CODE_OK && resp.Status.Code != rpc.Code_CODE_NOT_FOUND: + case resp.Status.Code != rpc.Code_CODE_OK: return resp, nil - case key == "": + case storageId == "": return resp, nil default: return resp, pushToCache(cache, key, resp)