From 39662b7863ad3ddfc10a9717d90e5f0305dd6cb0 Mon Sep 17 00:00:00 2001 From: Craig Peterson <192540+captncraig@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:50:51 -0400 Subject: [PATCH] pkg/reloader: use watchInterval timeout for initial apply (#6519) * pkg/reloader: use watchInterval timeout for initial apply Signed-off-by: Craig Peterson <192540+captncraig@users.noreply.github.com> * changelog Signed-off-by: Craig Peterson <192540+captncraig@users.noreply.github.com> * use distinct context for initial sync Signed-off-by: Craig Peterson <192540+captncraig@users.noreply.github.com> --------- Signed-off-by: Craig Peterson <192540+captncraig@users.noreply.github.com> --- CHANGELOG.md | 1 + pkg/reloader/reloader.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8740b70aac..9a58fb032b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6325](https://github.com/thanos-io/thanos/pull/6325) Store: return gRPC resource exhausted error for byte limiter. - [#6399](https://github.com/thanos-io/thanos/pull/6399) *: Fix double-counting bug in http_request_duration metric - [#6428](https://github.com/thanos-io/thanos/pull/6428) Report gRPC connnection errors in the logs. +- [#6519](https://github.com/thanos-io/thanos/pull/6519) Reloader: Use timeout for initial apply. - [#6509](https://github.com/thanos-io/thanos/pull/6509) Store Gateway: Remove `memWriter` from `fileWriter` to reduce memory usage when sync index headers. ### Changed diff --git a/pkg/reloader/reloader.go b/pkg/reloader/reloader.go index 1072026c2a..2057ea5f75 100644 --- a/pkg/reloader/reloader.go +++ b/pkg/reloader/reloader.go @@ -207,8 +207,10 @@ func (r *Reloader) Watch(ctx context.Context) error { if err := r.watcher.addFile(r.cfgFile); err != nil { return errors.Wrapf(err, "add config file %s to watcher", r.cfgFile) } - - if err := r.apply(ctx); err != nil { + initialSyncCtx, initialSyncCancel := context.WithTimeout(ctx, r.watchInterval) + err := r.apply(initialSyncCtx) + initialSyncCancel() + if err != nil { return err } }