From 2a75d40356e31c09cc823f1edeff0e9b217f66d5 Mon Sep 17 00:00:00 2001 From: "Jonathan Gonzalez V." Date: Wed, 2 Jul 2025 11:12:54 +0200 Subject: [PATCH] fix: logic to retrieve ObjectStore from cache (#429) There was mistake on the object used to compare the ObjectStore, we were using a type Secret instead of ObjectStore. Also, make it more clear the logic to retrieve the cached objects by getting the cached objects when are cached. Signed-off-by: Jonathan Gonzalez V. --- internal/cnpgi/instance/internal/client/client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/cnpgi/instance/internal/client/client.go b/internal/cnpgi/instance/internal/client/client.go index 6b5dbd3..e634532 100644 --- a/internal/cnpgi/instance/internal/client/client.go +++ b/internal/cnpgi/instance/internal/client/client.go @@ -11,6 +11,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" + + pluginBarman "github.com/cloudnative-pg/plugin-barman-cloud/api/v1" ) // DefaultTTLSeconds is the default TTL in seconds of cache entries @@ -48,7 +50,7 @@ func (e *ExtendedClient) isObjectCached(obj client.Object) bool { return true } - if _, isObjectStore := obj.(*corev1.Secret); isObjectStore { + if _, isObjectStore := obj.(*pluginBarman.ObjectStore); isObjectStore { return true } @@ -62,11 +64,11 @@ func (e *ExtendedClient) Get( obj client.Object, opts ...client.GetOption, ) error { - if !e.isObjectCached(obj) { - return e.Client.Get(ctx, key, obj, opts...) + if e.isObjectCached(obj) { + return e.getCachedObject(ctx, key, obj, opts...) } - return e.getCachedObject(ctx, key, obj, opts...) + return e.Client.Get(ctx, key, obj, opts...) } func (e *ExtendedClient) getCachedObject(