K8SPSMDB-1608 remove stale external-dns annotations when expose.externalDNS changes#2440
Open
nmarukovich wants to merge 4 commits into
Open
K8SPSMDB-1608 remove stale external-dns annotations when expose.externalDNS changes#2440nmarukovich wants to merge 4 commits into
nmarukovich wants to merge 4 commits into
Conversation
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a long-standing reconciliation issue where expose.externalDNS annotations on per-pod Services were only ever added/merged, but not removed when externalDNS was edited or removed from the CR—leaving ExternalDNS-managed DNS records active after the feature was effectively disabled.
Changes:
- Introduces a Percona marker annotation (
percona.com/external-dns-managed) and uses it to identify operator-managed ExternalDNS annotations. - Updates the Service reconciliation merge path to delete stale operator-managed
external-dnsannotations (hostname/ttl/marker) that are no longer desired. - Adds/updates unit tests and introduces an
external-dnsE2E test scenario, wiring it into PR/release test runs.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/psmdb/service.go | Switches ExternalDNS annotation keys to naming constants and adds the managed marker annotation to per-pod replset Services. |
| pkg/psmdb/service_test.go | Updates expected annotations for replset per-pod Services to include the managed marker. |
| pkg/psmdb/mongos.go | Switches ExternalDNS annotation keys to naming constants and adds the managed marker annotation to mongos Services. |
| pkg/psmdb/mongos_test.go | Adds test coverage validating mongos ExternalDNS annotations (single service vs service-per-pod, ttl, marker). |
| pkg/naming/annotations.go | Centralizes ExternalDNS-related annotation keys in pkg/naming. |
| pkg/controller/perconaservermongodb/psmdb_controller.go | Implements and invokes stale ExternalDNS annotation cleanup during Service updates when preserving old metadata. |
| pkg/controller/perconaservermongodb/service_test.go | Adds unit tests for stale ExternalDNS annotation removal behavior. |
| e2e-tests/run-release.csv | Adds the new external-dns E2E test to the release test suite. |
| e2e-tests/run-pr.csv | Adds the new external-dns E2E test to the PR test suite. |
| e2e-tests/external-dns/run | New E2E test validating annotation creation, ttl removal, externalDNS removal cleanup, and manual annotation preservation. |
| e2e-tests/external-dns/conf/external-dns.yml | New sharded cluster manifest used by the external-dns E2E test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "external-dns.alpha.kubernetes.io/ttl": "60", | ||
| }, | ||
| }, | ||
| "externalDNS enabled over manual annotations: operator takes ownership": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGE DESCRIPTION
Problem:
expose.externalDNS(added in #2280) writesexternal-dns.alpha.kubernetes.io/hostnameand
/ttlannotations to per-pod Services, but never removes them. When a user removesor edits
externalDNSin the CR, the old annotations stay on the Service (merge-onlyupdate path when no user annotations are set), so external-dns keeps live DNS records
for a feature that was turned off.
Cause:
Short explanation of the root cause of the issue if applicable.
Solution:
The operator now marks Services it manages with
percona.com/external-dns-managedand,on update, removes its own external-dns annotations that are no longer in the desired
state. Annotations added manually by the user (without the marker) are left untouched.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability