From 7c920383f52a58547bd6ac9ae161b553ca564111 Mon Sep 17 00:00:00 2001 From: Jon Huhn Date: Fri, 17 Feb 2023 16:25:42 -0600 Subject: [PATCH] fix tag delete following resource create --- azure/services/tags/tags.go | 11 ++++++----- azure/services/tags/tags_test.go | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/azure/services/tags/tags.go b/azure/services/tags/tags.go index 2f5aa5df538..c77146ece2f 100644 --- a/azure/services/tags/tags.go +++ b/azure/services/tags/tags.go @@ -105,13 +105,14 @@ func (s *Service) Reconcile(ctx context.Context) error { return errors.Wrap(err, "cannot update tags") } } - - // We also need to update the annotation if anything changed. - if err := s.Scope.UpdateAnnotationJSON(tagsSpec.Annotation, newAnnotation); err != nil { - return err - } log.V(2).Info("successfully updated tags") } + + // We also need to update the annotation even if nothing changed to + // ensure it's set immediately following resource creation. + if err := s.Scope.UpdateAnnotationJSON(tagsSpec.Annotation, newAnnotation); err != nil { + return err + } } return nil } diff --git a/azure/services/tags/tags_test.go b/azure/services/tags/tags_test.go index 1d6f1ffa796..139bf21397c 100644 --- a/azure/services/tags/tags_test.go +++ b/azure/services/tags/tags_test.go @@ -218,6 +218,7 @@ func TestReconcileTags(t *testing.T) { }, }}, nil) s.AnnotationJSON("my-annotation").Return(map[string]interface{}{"key": "value"}, nil) + s.UpdateAnnotationJSON("my-annotation", map[string]interface{}{"key": "value"}) }, }, }