Skip to content

telemetry: keep known peers when a discovery refresh fails - #4146

Merged
elitegreg merged 1 commit into
gm/telemetry-pinger-epoch-fallbackfrom
gm/telemetry-peer-cache-refresh
Aug 3, 2026
Merged

telemetry: keep known peers when a discovery refresh fails#4146
elitegreg merged 1 commit into
gm/telemetry-pinger-epoch-fallbackfrom
gm/telemetry-peer-cache-refresh

Conversation

@elitegreg

@elitegreg elitegreg commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Resolves: #4128

Independent of #4144 and #4145 (different file), so this one branches from main.

Summary of Changes

  • ledgerPeerDiscovery.refresh no longer empties the peer cache before doing work that can fail. It cleared p.peers under the lock and then called LocalNet.Interfaces(), so a transient failure there returned with zero peers and Pinger.Tick iterated an empty slice, probing nothing until a later refresh succeeded.
  • The cache is now replaced only once the new list is built, and the lock covers just that assignment rather than the whole build. The clear was redundant with the existing assignment at the end of the happy path.
  • Success path is unchanged.

Diff Breakdown

Category Files Lines (+/-) Net
Tests 1 +79 / -0 +79
Core logic 1 +6 / -5 +1
Docs 1 +3 / -0 +3
Total 3 +88 / -5 +83

A one-line behavioral fix plus the regression test that pins it.

Key files (click to expand)

Testing Verification

  • New test lets the first refresh discover a peer, then fails every subsequent LocalNet.Interfaces() call, and asserts GetPeers() still returns the fully populated peer (link, device, tunnel, TWAMP port) after at least three failed refreshes. It fails against the pre-fix code, which returns an empty list.
  • Existing peer discovery tests pass unchanged, covering the success path and the skip cases.
  • Package passes under -race, since the change moves what the mutex covers.

@elitegreg
elitegreg marked this pull request as ready for review August 3, 2026 16:01
@elitegreg
elitegreg enabled auto-merge (squash) August 3, 2026 16:01
@elitegreg
elitegreg force-pushed the gm/telemetry-peer-cache-refresh branch from 6576103 to c8a911b Compare August 3, 2026 16:56
@elitegreg
elitegreg changed the base branch from main to gm/telemetry-pinger-epoch-fallback August 3, 2026 16:56
@elitegreg
elitegreg merged commit cacceb9 into gm/telemetry-pinger-epoch-fallback Aug 3, 2026
42 of 47 checks passed
@elitegreg
elitegreg deleted the gm/telemetry-peer-cache-refresh branch August 3, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

device/telemetry: peer cache cleared before fallible work in refresh()

1 participant