From b0094b325e292aaa89e1be35b86858194a41e02d Mon Sep 17 00:00:00 2001 From: afayngelerindbx <38990103+afayngelerindbx@users.noreply.github.com> Date: Wed, 12 May 2021 04:44:00 -0400 Subject: [PATCH] Annotations: Prevent orphaned annotation tags cleanup when no annotations were cleaned (#33957) Fixes #33948 Co-authored-by: Anatoly Fayngelerin --- pkg/services/sqlstore/annotation_cleanup.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/services/sqlstore/annotation_cleanup.go b/pkg/services/sqlstore/annotation_cleanup.go index 78227366530..0f9a181777b 100644 --- a/pkg/services/sqlstore/annotation_cleanup.go +++ b/pkg/services/sqlstore/annotation_cleanup.go @@ -47,8 +47,9 @@ func (acs *AnnotationCleanupService) CleanAnnotations(ctx context.Context, cfg * if err != nil { return totalCleanedAnnotations, 0, err } - - affected, err = acs.cleanOrphanedAnnotationTags(ctx) + if totalCleanedAnnotations > 0 { + affected, err = acs.cleanOrphanedAnnotationTags(ctx) + } return totalCleanedAnnotations, affected, err }