Conversation
…data extension is active When the k8smetadata extension is configured, the kubernetesResolver is initialized without a safeStopCh (the extension manages its own lifecycle). The Stop() method unconditionally called safeStopCh.Close(), causing a nil pointer dereference (SIGSEGV) during shutdown. Add a nil check before calling Close() to prevent the panic. This matches the existing pattern used in the k8smetadata extension's own Shutdown() method. Fixes #1743
sky333999
approved these changes
Apr 30, 2026
JayPolanco
approved these changes
Apr 30, 2026
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.
Summary
Fix a nil pointer dereference (SIGSEGV) panic in
kubernetesResolver.Stop()that occurs during agent shutdown when thek8smetadataextension is configured.Fixes #1743
Problem
When the
k8smetadataextension is present in the agent configuration, thekubernetesResolveris initialized via a code path that does not allocate asafeStopCh(the extension manages its own lifecycle independently). However,Stop()unconditionally callse.safeStopCh.Close(), causing a nil pointer dereference panic during shutdown.The panic stack trace looks like:
Fix
Add a nil check before calling
Close()onsafeStopCh. This matches the existing pattern already used in thek8smetadataextension's ownShutdown()method (extension/k8smetadata/extension.go).Testing
Unit Tests
All existing tests pass, including
TestEksResolver/Test_Stop:End-to-End Before/After EKS Verification
Tested on an EKS 1.30 cluster (2 managed nodes,
t3.medium) with the CloudWatch Observability addon (v5.3.1-eksbuild.1), which enables thek8smetadataextension + Application Signals pipeline — the exact configuration that triggers the bug.Both before and after confirmed
k8smetadataextension active:Shutdown was triggered by sending SIGTERM to PID 1 inside the agent container via
kubectl debug, which exercises the exactStop()→safeStopCh.Close()code path.BEFORE (unfixed
1.300066.0b1367) — panic on every shutdown:Container crashed and restarted (restart count: 1).
AFTER (this PR) — clean shutdown, 3/3 tests:
No panic, no SIGSEGV. Container restarted cleanly (restart count: 1, from SIGTERM — not a crash).
1.300066.0b1367(unfixed)kubernetes.go:239e3addeb)Shutdown complete.e3addeb)Shutdown complete.e3addeb)Shutdown complete.