AKS icon indicating copy to clipboard operation
AKS copied to clipboard

[BUG] LocalDNS unit left dead after unclean restart (orphan coredns in cgroup) -> node-local DNS blackhole

Open ChrisRichner opened this issue 3 months ago • 6 comments

What happened:

With LocalDNS mode: Preferred on a System pool, localdns.service intermittently fails to restart: a prior run terminates uncleanly and leaves an orphan coredns in its delegated cgroup, systemd can't kill the cgroup, restarts trip the StartLimit, and the unit is left dead. Pods pointed at 169.254.10.11 then get no DNS and no fallback until a manual systemctl restart localdns.

localdns.service: Found left-over process <pid> (coredns) in control group while starting unit. Ignoring.
localdns.service: This usually indicates unclean termination of a previous run...
localdns.service: Failed to kill control group /localdns.slice/localdns.service, ignoring: Invalid argument
localdns.service: Start request repeated too quickly.
Failed to start localdns.service

Impact: ~16 min DNS blackhole per node (e.g. dead 17:47:12 -> 18:03:41 UTC); 7 of 8 pool nodes hit it within 48h, right after an automatic patch upgrade reimaged the pool.

Expected: localdns should clean up the previous run's cgroup before restart (or not StartLimit itself into a dead state); a dead local resolver shouldn't blackhole DNS.

Key point: reproduces on the latest node image. A node-image upgrade does not fix it.

Environment:

  • K8s 1.36.3; node image AKSUbuntu-2404gen2containerd-202608.06.1 (Ubuntu 24.04, kernel 6.8.0-1065-azure)
  • Azure CNI; System pool; LocalDNS Preferred/Enabled (AKS default, not user-set); West Europe

Ruled out: CoreDNS healthy (3/3); conntrack ~720/131072; subnet ~62% used. Not IP/conntrack starvation.

Mitigation: setting localDNSProfile.mode = Disabled on the pool removes the failure; pools without LocalDNS are unaffected. Requesting a fix to the localdns cgroup teardown + restart handling.

I've also raised this via Azure support (case 2607310050001328) for tracking. Happy to link the two so the investigation stays in sync, and to validate a fixed node image whenever one is ready. Thanks!

ChrisRichner avatar Aug 27 '26 14:08 ChrisRichner

SR (from original post): case 2607310050001328

sjwaight avatar Aug 28 '26 03:08 sjwaight

@ChrisRichner I believe the support team asked for some additional information from you in relation to the SR # you shared. If you're able to provide that via the support channel that would be amazing as it will help us to investigate further.

sjwaight avatar Aug 31 '26 22:08 sjwaight

Hi there :wave: AKS bot here.

Thank you for reporting this bug to the AKS team.

This issue has been tagged as 'fixing' as a bug fix is currently in progress.

When the fix is complete, we will update you with the investigation and fix details.

Thank you!

PR to fix: https://github.com/Azure/AgentBaker/pull/9360

saewoni avatar Sep 02 '26 22:09 saewoni

Hi there,

Thank you for working on and providing a fix for this issue.

It looks like the PR has been inactive for a while. Do you have an estimated timeline for when the fix might be merged and become available for use in AKS?

Thank you in advance for any update.

ChrisRichner avatar Sep 14 '26 08:09 ChrisRichner

Hi, I wanted to clarify the distinction between these PRs.

The failure loop was caused by wait_for_localdns_removed_from_resolv_conf() treating a temporarily empty resolv.conf as a successful refresh. localdns.service then read no upstream DNS servers, exited quickly, and restarted rapidly until systemd's start-rate limiter left the service in the failed state.

AgentBaker PR #9361 is the direct root-cause fix. It requires the resolver state to contain at least one nameserver before continuing, which breaks this specific feedback loop.

AgentBaker PR #9360 is a separate defense-in-depth fix. It adds a systemd ExecStopPost cleanup hook to restore node-level DNS if localdns.service exits unexpectedly without running its shell cleanup. It does not fix the empty-resolver feedback loop, and it does not restore pod DNS configured to 169.254.10.11.

Pod-level DNS recovery will be addressed in a separate follow-up PR; that work has not been implemented yet.

saewoni avatar Sep 14 '26 18:09 saewoni