Raise when sendmsg fails for every resolved address#23
Merged
Conversation
Previously sendmsg warned on each failed UDP send and auth always returned the full address list. Hosts with both IPv4 and IPv6 records on networks lacking v6 routing produced noisy 'No route to host' warnings even when the v4 path succeeded. Drop the per-packet warn, rescue SystemCallError per address in auth, and raise Sparoid::Error only when no address accepted the send. Return only the successful addresses so fdpass skips unreachable peers.
Contributor
Author
|
Lazy me didn't wanna go the Bring your own logger path. Just silence the error logs for now :) Tested locally with ssh-monitor |
antondalgren
approved these changes
May 6, 2026
There was a problem hiding this comment.
Pull request overview
This PR adjusts SPA packet sending behavior to avoid noisy per-packet warnings on partial connectivity (e.g., dual-stack hosts on v4-only networks), and instead only raises an error when all resolved destination addresses fail. It also returns only the addresses that successfully received packets so downstream connection logic can skip unreachable peers.
Changes:
- Update
Sparoid.authto rescueSystemCallErrorper resolved address, collecting failures and raisingSparoid::Erroronly if every address fails. - Change
Sparoid.authto return only the subset of addresses that were successfully sent to. - Remove
sendmsgper-packet warning behavior and make socket cleanup resilient when socket creation fails.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/sparoid.rb | Implements per-address failure handling in auth, returns only successful addrs, and removes sendmsg warning behavior while hardening socket close. |
| test/sparoid_test.rb | Adds tests for “all addresses fail => raises” and “partial failure => returns only successful addrs with no stderr noise”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
warn \"Sparoid error: ...\"insendmsg— hosts with both v4 and v6 addresses on v4-only networks were spammingNo route to hosteven when the other path worked.authnow rescuesSystemCallErrorper address, collects the failed-addr error messages, and raisesSparoid::Erroronly when every address failed.authreturns the list of successful addresses sofdpassdoesn't try unreachable peers.Test plan
bundle exec rake test(23 runs, 42 assertions, 0 failures)bundle exec rubocop(clean)