Skip to content

Commit b97debf

Browse files
committed
query: retry initial DNS resolution instead of becoming ready with missing endpoints
The initial resolution ran once and a failure was only logged, so a transient DNS error at startup let the querier become ready with a partial endpoint list. Retry every 2s until every address resolves or --store.sd-dns-interval elapses. Signed-off-by: Sang Hyun Lee <shyundev@gmail.com>
1 parent e3bceed commit b97debf

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
1818

1919
### Fixed
2020

21+
- [#9033](https://github.com/thanos-io/thanos/pull/9033): Query: Retry the initial DNS resolution of endpoints for up to `--store.sd-dns-interval` instead of becoming ready with a partial endpoint list after a transient DNS failure.
2122
- [#9014](https://github.com/thanos-io/thanos/pull/9014): Reloader: Optimize `Watch` to allocate constant memory despite the config size.
2223
- [#8990](https://github.com/thanos-io/thanos/pull/8990): Receive: Avoid a panic when pruning starts before a tenant TSDB is ready.
2324
- [#8968](https://github.com/thanos-io/thanos/pull/8968): *: Bump `google.golang.org/grpc` to v1.82.1 to fix GHSA-hrxh-6v49-42gf (CVSS 8.6): HTTP/2 Rapid Reset DoS bypass, xDS RBAC authorization bypass, and NOT-rule panic.

cmd/thanos/endpointset.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ func setupEndpointSet(
370370

371371
// Perform initial DNS resolution before starting periodic updates.
372372
// This ensures that DNS providers have addresses when the first endpoint update runs.
373+
// Resolution is retried until every address resolves or the interval elapses, so that
374+
// the first update sees the full endpoint list even when DNS fails transiently at startup.
373375
{
374376
resolveCtx, resolveCancel := context.WithTimeout(context.Background(), dnsSDInterval)
375377
defer resolveCancel()
@@ -387,7 +389,13 @@ func setupEndpointSet(
387389
}
388390
// Note: legacyFileSDCache will be empty at this point since file SD hasn't started yet
389391
if len(addresses) > 0 {
390-
if err := dnsEndpointProvider.Resolve(resolveCtx, addresses, true); err != nil {
392+
if err := runutil.Retry(2*time.Second, resolveCtx.Done(), func() error {
393+
if err := dnsEndpointProvider.Resolve(resolveCtx, addresses, true); err != nil {
394+
level.Warn(logger).Log("msg", "initial DNS resolution failed, retrying", "err", err)
395+
return err
396+
}
397+
return nil
398+
}); err != nil {
391399
level.Error(logger).Log("msg", "initial DNS resolution failed", "err", err)
392400
}
393401
}

0 commit comments

Comments
 (0)