Commit 5f78ae0
feat(opensearchtransport): add default-on client-side DNS caching (#902)
* feat(opensearchtransport): add default-on client-side DNS caching
Transient resolver outages (e.g. a node-local DNS blip producing
"dial tcp: lookup ...: i/o timeout") fail requests even to nodes whose
addresses were already resolved, because the default transport re-resolves
every dial through the system resolver with no cache to fall back on.
DNS-timeout errors are also not retried under the default config.
Install a process-local DNS cache (github.com/rs/dnscache) on the built-in
transport, enabled by default. Resolved addresses are cached and re-resolved
on an interval (default 60s, mirroring the TTL AWS publishes for managed
OpenSearch Service endpoints); when the resolver is briefly unreachable, the
last-known-good address continues to be served until it recovers, so a
transient DNS outage no longer fails requests to already-resolved hosts. A
node that genuinely moved self-corrects: the stale IP fails to dial, the
connection is marked dead, and routing skips it.
Tune or disable via the DNSCacheRefresh config field or
OPENSEARCH_GO_DNS_CACHE_REFRESH (0 = default, <0 = disable, >0 = explicit
interval). Caching is installed only when no custom Transport is supplied; a
caller-provided Transport is never modified. The refresh goroutine is bound to
the transport root context, so Close() reclaims it. Because Go's resolver does
not expose record TTLs, the interval is a re-resolution cadence, not a
per-record TTL.
Expose DNSLookups, DNSCacheMisses, and DNSLookupErrors counters via
Transport.Metrics(), mirroring the existing AddressResolver* counters.
* feat(opensearchtransport): make DNS dialer timeout and keep-alive configurable
Thread the net.Dialer dial timeout and keep-alive behind the client-side
DNS cache through Config (DNSDialTimeout, DNSKeepAlive) and matching
OPENSEARCH_GO_DNS_DIAL_TIMEOUT / OPENSEARCH_GO_DNS_KEEP_ALIVE env vars,
mirroring the existing DNSCacheRefresh pattern. Previously these were
hardcoded 30s constants with no code- or env-level override.
Bundle the three resolved durations into a dnsCacheSettings value so the
dialer constructor keeps a small signature.
---------
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
Signed-off-by: Ryan Yuan <ryan.yuan@crowdstrike.com>
Co-authored-by: Sean Chittenden <sean.chittenden@crowdstrike.com>1 parent 3c2cd17 commit 5f78ae0
15 files changed
Lines changed: 1396 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
50 | 71 | | |
51 | 72 | | |
52 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
123 | 145 | | |
124 | 146 | | |
125 | 147 | | |
| |||
318 | 340 | | |
319 | 341 | | |
320 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
321 | 348 | | |
322 | 349 | | |
323 | 350 | | |
| |||
0 commit comments