From a3c4d004e1d5992a5c8fa7e457658faeedd9f688 Mon Sep 17 00:00:00 2001 From: ermakov-oleg Date: Thu, 12 Feb 2026 16:08:42 +0100 Subject: [PATCH] fix: deduplicate Archive object references to prevent duplicate volume projections Port of upstream PR #331. When the same Archive is referenced multiple times (e.g. as both archive and recovery), volume projections were duplicated causing Job creation failures. Signed-off-by: ermakov-oleg --- internal/cnpgi/operator/config/config.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/internal/cnpgi/operator/config/config.go b/internal/cnpgi/operator/config/config.go index 52641862..91a0787b 100644 --- a/internal/cnpgi/operator/config/config.go +++ b/internal/cnpgi/operator/config/config.go @@ -101,19 +101,27 @@ func (config *PluginConfiguration) GetReplicaSourceArchiveObjectKey() types.Name } } -// GetReferredArchiveObjectsKey gets the list of pgbackrest archive objects referred by -// this plugin configuration +// GetReferredArchiveObjectsKey gets the deduplicated list of pgbackrest archive objects +// referred by this plugin configuration func (config *PluginConfiguration) GetReferredArchiveObjectsKey() []types.NamespacedName { + seen := make(map[types.NamespacedName]struct{}, 3) result := make([]types.NamespacedName, 0, 3) + addUnique := func(key types.NamespacedName) { + if _, exists := seen[key]; !exists { + seen[key] = struct{}{} + result = append(result, key) + } + } + if len(config.PgbackrestObjectName) > 0 { - result = append(result, config.GetArchiveObjectKey()) + addUnique(config.GetArchiveObjectKey()) } if len(config.RecoveryPgbackrestObjectName) > 0 { - result = append(result, config.GetRecoveryArchiveObjectKey()) + addUnique(config.GetRecoveryArchiveObjectKey()) } if len(config.ReplicaSourcePgbackrestObjectName) > 0 { - result = append(result, config.GetReplicaSourceArchiveObjectKey()) + addUnique(config.GetReplicaSourceArchiveObjectKey()) } return result