Skip to content

geoprobe: create sockets on-demand instead of holding them open per target#3378

Draft
ben-dz wants to merge 1 commit intomainfrom
bdz/geoprobe-on-demand-sockets
Draft

geoprobe: create sockets on-demand instead of holding them open per target#3378
ben-dz wants to merge 1 commit intomainfrom
bdz/geoprobe-on-demand-sockets

Conversation

@ben-dz
Copy link
Contributor

@ben-dz ben-dz commented Mar 25, 2026

Summary of Changes

  • Replace persistent per-target sender pairs with on-demand socket creation: sockets are now created at probe time and closed immediately after, eliminating long-lived ephemeral port consumption
  • Pinger tracks only target addresses (not sender objects), and creates/closes sender pairs in probeTarget() during each measurement cycle
  • Extract createSenderPair() and probeTarget() helpers to consolidate duplicated probe logic from probeWorker and MeasureOne
  • Introduce senderFactory function type for test injection, replacing direct senderEntry struct manipulation in tests

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 1 +102 / -155 -53
Tests 1 +76 / -63 +13

Net code reduction; the core change simplifies the pinger by removing persistent socket management.

Key files (click to expand)
  • controlplane/telemetry/internal/geoprobe/pinger.go — replaced senders map[string]*senderEntry with targets map[string]ProbeAddress; added createSenderPair() and probeTarget() for on-demand socket lifecycle; simplified Close() to just clear the target map
  • controlplane/telemetry/internal/geoprobe/pinger_test.go — switched tests from injecting senderEntry structs to using a mockFactory for senderFactory; updated all assertions from senders to targets

Testing Verification

  • Unit tests updated to use senderFactory injection pattern; all existing test scenarios (dual-probe min RTT, one-fails-uses-other, both-fail, concurrent add/remove, MeasureOne) preserved
  • Large-scale and concurrent test coverage unchanged

@ben-dz ben-dz added this to the Geo Location milestone Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant