Commit 9aa4d2a
authored
Warn on partial UDP send failure, raise SendError when all fail (#23)
* Log UDP send failures as warnings, not errors
A host with both A and AAAA records on a network with no route for one
family (e.g. v4-only network with AAAA record) will fail the send for
the unreachable family while the other family succeeds. The previous
"Sparoid error sending ..." wording made the partial failure look
fatal; reword to "Sparoid warn: skip <ip>: <reason>" to make clear it
is recoverable, mirroring sparoid.rb#20.
* Include hostname in UDP send warning
* Suppress per-address UDP send errors when one family succeeds
When a host resolves to both A and AAAA addresses but the network only
routes one family, the unreachable family's send raises EHOSTUNREACH.
Previously every per-addr failure was logged, which is noisy when the
other family's send succeeded and the call as a whole worked. Collect
errors and only log them if every address failed; include the original
hostname alongside the IP for easier triage.
* Extract send_errors_to_report helper and unit-test it
The previous integration tests relied on "send to 0.0.0.0 fails with
EHOSTUNREACH" to exercise the all-failed branch, which is true on
macOS but not on the Linux CI runners where the kernel accepts the
send. Extract the error-reporting decision into a pure helper that can
be unit-tested with synthetic inputs, independent of OS networking
behavior.
* Raise SendError when no UDP send succeeds, warn on partial failure
- Per-address failure with at least one success: STDERR warn line
("Sparoid warn: skip <host> (<ip>): <reason>") so v4-only networks
don't make AAAA-resolved hosts log catastrophically.
- Every address failed: raise Sparoid::Client::SendError with all
per-address details. The CLI already catches and exits 1, so this
surfaces a clear actionable failure instead of returning quietly and
failing later in fdpass.
* Emit partial-failure warnings via Log.warn instead of raw STDERR
Apps embedding sparoid as a shard at scale (15k+ servers) need partial
UDP send failures classified as WARN-level by their monitoring, not as
ERROR-level (which most aggregators infer from STDERR by default).
- Sparoid::Client::Log = ::Log.for(self) declares a log source so apps
can filter sparoid output specifically.
- udp_send emits per-address skips via Log.warn { ... }.
- client-cli configures Log.setup_from_env with an STDERR backend (in
:connect mode STDOUT is the unix-domain FD-passing channel and isn't
safe for free-form output).
* Address PR review: drop redundant prefix, test send-result branching
- SendError no longer prepends 'Sparoid:' to the message — the CLI's
rescue clause already prefixes 'Sparoid error:', so the previous
format produced 'Sparoid error: Sparoid: failed to send...'.
- Replace the format_send_errors formatting helper with a
process_send_results helper that owns the partial-vs-total decision.
This raises SendError directly when every send failed and returns
the per-address partial-failure errors otherwise.
- Specs now cover both branches plus the all-succeeded and
empty-input cases, exercising the actual control flow rather than
just message formatting.1 parent 9a95e49 commit 9aa4d2a
3 files changed
Lines changed: 70 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
74 | 81 | | |
75 | 82 | | |
76 | | - | |
| 83 | + | |
77 | 84 | | |
78 | 85 | | |
| 86 | + | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | | - | |
| 92 | + | |
85 | 93 | | |
86 | 94 | | |
87 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
92 | 115 | | |
93 | 116 | | |
94 | 117 | | |
| |||
0 commit comments