From c1eaaaa3be95e423b92f205a768abb8ee19a1be3 Mon Sep 17 00:00:00 2001 From: alty1224 Date: Thu, 27 Feb 2025 12:47:43 +0500 Subject: [PATCH 1/3] add err logs for duplicate prefix --- backup/backup.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backup/backup.go b/backup/backup.go index 55eda96..20a42f2 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -666,9 +666,11 @@ func (bp BackupProvider) checkPrefixUniqueness(prefix string, ctx context.Contex } for element, user := range users { if strings.HasPrefix(element, prefix) { + logger.ErrorContext(ctx, fmt.Sprintf("provided prefix already exists or a part of another prefix: %+v", prefix)) return false, fmt.Errorf("provided prefix already exists or a part of another prefix: %+v", prefix) } if user.Attributes[resourcePrefixAttributeName] != "" && strings.HasPrefix(user.Attributes[resourcePrefixAttributeName], prefix) { + logger.ErrorContext(ctx, fmt.Sprintf("provided prefix already exists or a part of another prefix: %+v", prefix)) return false, fmt.Errorf("provided prefix already exists or a part of another prefix: %+v", prefix) } } From e8e09c72622f7080b72afd8189ddac43c3b0a793 Mon Sep 17 00:00:00 2001 From: alty1224 Date: Fri, 28 Feb 2025 15:03:08 +0500 Subject: [PATCH 2/3] test --- backup/backup.go | 3 +++ basic/basic.go | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/backup/backup.go b/backup/backup.go index 20a42f2..d7e3f14 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -599,9 +599,12 @@ func (bp BackupProvider) ProcessRestorationRequest(backupId string, restorationR var changedDbNames map[string]string prefixes := make(map[string]struct{}) for _, dabatase := range restorationRequest.Databases { + logger.Info("CCCCCCCCCCCCCCCCCCCC") dbs = append(dbs, fmt.Sprintf(`"%s"`, dabatase.Name)) if restorationRequest.RegenerateNames { + logger.Info("BBBBBBBBBBBBBB") if dabatase.Prefix != "" { + logger.Info("AAAAAAAAAAAAAAAAA") if ok, err := bp.checkPrefixUniqueness(dabatase.Prefix, ctx); ok { if err != nil { return nil, err, "" diff --git a/basic/basic.go b/basic/basic.go index 26b0b71..a52a56e 100644 --- a/basic/basic.go +++ b/basic/basic.go @@ -332,12 +332,6 @@ func (bp BaseProvider) createDatabase(requestOnCreateDb DbCreateRequest, ctx con } } - if ok, err := common.CheckPrefixUniqueness(prefix, ctx, bp.opensearch.Client); !ok { - if err != nil { - return nil, err - } - } - resourcesToCreate := requestOnCreateDb.Settings.CreateOnly if len(resourcesToCreate) == 0 { resourcesToCreate = []string{common.UserKind, common.IndexKind} From 20ea36bb465cc2231be1a0ca2e5eda094c5966dc Mon Sep 17 00:00:00 2001 From: alty1224 Date: Fri, 28 Feb 2025 15:14:25 +0500 Subject: [PATCH 3/3] clean --- backup/backup.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/backup/backup.go b/backup/backup.go index d7e3f14..20a42f2 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -599,12 +599,9 @@ func (bp BackupProvider) ProcessRestorationRequest(backupId string, restorationR var changedDbNames map[string]string prefixes := make(map[string]struct{}) for _, dabatase := range restorationRequest.Databases { - logger.Info("CCCCCCCCCCCCCCCCCCCC") dbs = append(dbs, fmt.Sprintf(`"%s"`, dabatase.Name)) if restorationRequest.RegenerateNames { - logger.Info("BBBBBBBBBBBBBB") if dabatase.Prefix != "" { - logger.Info("AAAAAAAAAAAAAAAAA") if ok, err := bp.checkPrefixUniqueness(dabatase.Prefix, ctx); ok { if err != nil { return nil, err, ""