Skip to content

[fix] Removing Stale DNS Entries #1083

Merged
komer3 merged 1 commit into
linode:mainfrom
bren-ak:fix/dns-entries
Jun 23, 2026
Merged

[fix] Removing Stale DNS Entries #1083
komer3 merged 1 commit into
linode:mainfrom
bren-ak:fix/dns-entries

Conversation

@bren-ak

@bren-ak bren-ak commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

  • Add a watch to the LinodeCluster controller for Machine objects.
  • Remove getMachineIPs for getDNSMachineIPs to remove duplicate list creation and ensure accurate stale record deletions.

The added watch for Machine objects to the LinodeCluster helps improve the timing of DNS record clean ups as the LinodeMachine does not get a call for deletion until the node has been drained. In addition the change to the function for DNS list entries to be removed has been modified to be built off of the state of Machine objects being deleted rather than completely deleted LinodeMachines (where the finalizer has been removed and the object is gone).

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.25%. Comparing base (f4e2145) to head (643cac1).

Files with missing lines Patch % Lines
...nal/controller/linodecluster_controller_helpers.go 0.00% 27 Missing ⚠️
internal/controller/linodecluster_controller.go 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1083      +/-   ##
==========================================
+ Coverage   69.23%   69.25%   +0.01%     
==========================================
  Files          71       71              
  Lines        6566     6589      +23     
==========================================
+ Hits         4546     4563      +17     
- Misses       1725     1735      +10     
+ Partials      295      291       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves DNS load balancer record cleanup for LinodeClusters by reconciling earlier during CAPI Machine deletion and by basing stale DNS pruning on the “current desired” DNS entry set (excluding deleting Machines), reducing the chance of leaving stale A/AAAA records behind.

Changes:

  • Add a Machine watch to the LinodeCluster controller to trigger reconciliation when Machines enter deletion.
  • Refactor stale DNS cleanup (Linode + Akamai) to use the computed dnsEntries list rather than rebuilding IP lists from LinodeMachine state.
  • Add a unit test ensuring stale Linode DNS records are deleted for deleting CAPI Machines.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/controller/linodecluster_controller.go Adds a Machine watch with predicates to trigger LinodeCluster reconciliation during Machine deletion.
internal/controller/linodecluster_controller_helpers.go Adds mapping from Machine events to the corresponding LinodeCluster reconcile request.
cloud/services/domains.go Refactors stale DNS deletion logic to use desired dnsEntries (and removes the older IP-list builder).
cloud/services/domains_test.go Adds a unit test validating stale Linode DNS record deletion when a CAPI Machine is deleting.

Comment thread internal/controller/linodecluster_controller.go
Comment thread internal/controller/linodecluster_controller_helpers.go
@bren-ak bren-ak temporarily deployed to prod-external June 23, 2026 15:06 — with GitHub Actions Inactive
@bren-ak bren-ak deployed to prod-external June 23, 2026 15:06 — with GitHub Actions Active

@komer3 komer3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@komer3 komer3 merged commit c494bbe into linode:main Jun 23, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants