Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reconcile annotation on reconciliation #406

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/dns/provider/state_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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() {
Expand Down
22 changes: 22 additions & 0 deletions test/integration/compound/compound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
Loading