Repository navigation
fix(agent): initialize SnapshotCache resource maps to avoid nil-map panic - #73
Merged
Merged
Conversation
…anic LoadListenersFromStorage assigns to c.listeners without a lazy nil-init (unlike AddPod), so the agent panicked with "assignment to entry in nil map" on restart when pods already existed in local storage — PreListen loads them before any AddPod runs. It stayed latent because agents previously started with empty storage, and the unit tests pre-initialized the map via a helper. Initialize the listeners, clusters, and secrets maps in NewSnapshotCache so no code path can assign to a nil map. Add a regression test that loads pods into a freshly constructed cache without manual map init. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Problem
The agent panics with
assignment to entry in nil mapon restart when pods already exist in local storage:LoadListenersFromStorageassigns toc.listenerswithout a lazy nil-init (unlikeAddPod, which guards it).PreListenruns it before anyAddPod, so on a restart with persisted pods the map is still nil. It stayed latent because agents previously started with empty local storage, and the unit tests masked it by pre-initializing the map via a helper.Surfaced deploying the merged agent to talos-main: the node that already had managed pods (
echo/client) crash-looped, while empty nodes came up fine.Fix
Initialize
listeners,clusters, andsecretsinNewSnapshotCacheso no path can assign to a nil map. Adds a regression test that loads pods into a freshly constructed cache (no manual init).