From 84eba7641906d9b6f488e673635ab8a9666c4972 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 0000000000..e8e89fc7c3 --- /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 ad66f55752..535ae7b9d7 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)