Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/reloader: use watchInterval timeout for initial apply #6519

Merged
merged 4 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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.

### Changed
- [#6049](https://github.com/thanos-io/thanos/pull/6049) Compact: *breaking :warning:* Replace group with resolution in compact metrics to avoid cardinality explosion on compact metrics for large numbers of groups.
Expand Down
7 changes: 5 additions & 2 deletions pkg/reloader/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,14 @@ func (r *Reloader) Watch(ctx context.Context) error {
}

defer runutil.CloseWithLogOnErr(r.logger, r.watcher, "config watcher close")
applyCtx, applyCancel := context.WithTimeout(ctx, r.watchInterval)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability maybe we can use different variable names, initialSyncCtx and initialSyncCancel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good thought. I made that change.


if r.cfgFile != "" {
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 {
if err := r.apply(applyCtx); err != nil {
return err
}
}
Expand Down Expand Up @@ -238,7 +239,9 @@ func (r *Reloader) Watch(ctx context.Context) error {
"out", r.cfgOutputFile,
"dirs", strings.Join(r.watchedDirs, ","))

applyCtx, applyCancel := context.WithTimeout(ctx, r.watchInterval)
// Reset the watch timeout.
applyCancel()
applyCtx, applyCancel = context.WithTimeout(ctx, r.watchInterval)

for {
select {
Expand Down
Loading