Skip to content

Commit 7bc81c1

Browse files
authored
Merge pull request #3187 from nojnhuh/fix-tag-delete
fix tag delete following resource create
2 parents f2bbf36 + 7c92038 commit 7bc81c1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

azure/services/tags/tags.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,14 @@ func (s *Service) Reconcile(ctx context.Context) error {
105105
return errors.Wrap(err, "cannot update tags")
106106
}
107107
}
108-
109-
// We also need to update the annotation if anything changed.
110-
if err := s.Scope.UpdateAnnotationJSON(tagsSpec.Annotation, newAnnotation); err != nil {
111-
return err
112-
}
113108
log.V(2).Info("successfully updated tags")
114109
}
110+
111+
// We also need to update the annotation even if nothing changed to
112+
// ensure it's set immediately following resource creation.
113+
if err := s.Scope.UpdateAnnotationJSON(tagsSpec.Annotation, newAnnotation); err != nil {
114+
return err
115+
}
115116
}
116117
return nil
117118
}

azure/services/tags/tags_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ func TestReconcileTags(t *testing.T) {
218218
},
219219
}}, nil)
220220
s.AnnotationJSON("my-annotation").Return(map[string]interface{}{"key": "value"}, nil)
221+
s.UpdateAnnotationJSON("my-annotation", map[string]interface{}{"key": "value"})
221222
},
222223
},
223224
}

0 commit comments

Comments
 (0)