diff --git a/pkg/dns/provider/state_entry.go b/pkg/dns/provider/state_entry.go index 85c110ea..40e14b4d 100644 --- a/pkg/dns/provider/state_entry.go +++ b/pkg/dns/provider/state_entry.go @@ -17,6 +17,7 @@ import ( "github.com/gardener/external-dns-management/pkg/dns" perrs "github.com/gardener/external-dns-management/pkg/dns/provider/errors" dnsutils "github.com/gardener/external-dns-management/pkg/dns/utils" + "github.com/gardener/gardener/pkg/apis/core/v1beta1/constants" "k8s.io/utils/ptr" ) @@ -250,6 +251,17 @@ func (this *state) HandleUpdateEntry(logger logger.LogContext, op string, object defer old.lock.Unlock() } + if object.GetAnnotations()[constants.GardenerOperation] == constants.GardenerOperationReconcile { + _, err := object.Modify(func(data resources.ObjectData) (bool, error) { + annotations := data.GetAnnotations() + delete(annotations, constants.GardenerOperation) + return true, nil + }) + if err != nil { + return reconcile.Delay(logger, err) + } + } + if ignored, annotation := ignoredByAnnotation(object); ignored { var err error if !object.IsDeleting() { diff --git a/test/integration/compound/compound_test.go b/test/integration/compound/compound_test.go index d9fe5d5b..c3ba4a78 100644 --- a/test/integration/compound/compound_test.go +++ b/test/integration/compound/compound_test.go @@ -12,6 +12,7 @@ import ( "github.com/gardener/controller-manager-library/pkg/controllermanager" "github.com/gardener/external-dns-management/pkg/dns" "github.com/gardener/external-dns-management/pkg/dns/provider" + "github.com/gardener/gardener/pkg/apis/core/v1beta1/constants" . "github.com/gardener/gardener/pkg/utils/test/matchers" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -410,6 +411,27 @@ var _ = Describe("Compound controller tests", func() { By("check mock database") checkSingleEntryInMockDatabase(nil) }) + + It("should remove the Gardener reconcile operation annotation after reconciliation", func() { + By("Create new DNS entry") + Expect(testClient.Create(ctx, e1)).To(Succeed()) + DeferCleanup(func() { + Expect(testClient.Delete(ctx, e1)).To(Succeed()) + }) + checkEntry(e1) + + By("Set reconcile annotation on DNS entry") + e1.Annotations = map[string]string{ + constants.GardenerOperation: constants.GardenerOperationReconcile, + } + Expect(testClient.Update(ctx, e1)).To(Succeed()) + + By("Wait for the reconcile annotation to be removed from the DNS entry") + Eventually(func(g Gomega) { + g.Expect(testClient.Get(ctx, client.ObjectKeyFromObject(e1), e1)).To(Succeed()) + g.Expect(e1.Annotations).NotTo(HaveKey(constants.GardenerOperation)) + }).Should(Succeed()) + }) }) func quoted(txt []string) []string {