Skip to content

Commit

Permalink
*: Remove unnecessary configuration reload from ContentPathReloader
Browse files Browse the repository at this point in the history
… and improve its tests (thanos-io#6496)

* Fix and improve PathContentReloader tests

Signed-off-by: Douglas Camata <[email protected]>

* Run tests in parallel

Signed-off-by: Douglas Camata <[email protected]>

* Add changelog entry

Signed-off-by: Douglas Camata <[email protected]>

* Fix table tests

Signed-off-by: Douglas Camata <[email protected]>

* Fix typo

Co-authored-by: Filip Petkovski <[email protected]>
Signed-off-by: Douglas Camata <[email protected]>

* Rerun CI

Signed-off-by: Douglas Camata <[email protected]>

* Rerun CI

Signed-off-by: Douglas Camata <[email protected]>

---------

Signed-off-by: Douglas Camata <[email protected]>
Co-authored-by: Filip Petkovski <[email protected]>
Signed-off-by: Giedrius Statkevičius <[email protected]>
  • Loading branch information
2 people authored and GiedriusS committed Jul 27, 2023
1 parent 4044328 commit d3d658c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#6441](https://github.com/thanos-io/thanos/pull/6441) Compact: Compactor will set `index_stats` in `meta.json` file with max series and chunk size information.

### Fixed

- [#6496](https://github.com/thanos-io/thanos/pull/6496): *: Remove unnecessary configuration reload from `ContentPathReloader` and improve its tests.
- [#6456](https://github.com/thanos-io/thanos/pull/6456) Store: fix crash when computing set matches from regex pattern
- [#6427](https://github.com/thanos-io/thanos/pull/6427) Receive: increasing log level for failed uploads to error
- [#6172](https://github.com/thanos-io/thanos/pull/6172) query-frontend: return JSON formatted errors for invalid PromQL expression in the split by interval middleware.
Expand Down
1 change: 1 addition & 0 deletions pkg/extkingpin/path_content_reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func PathContentReloader(ctx context.Context, fileContent fileContent, logger lo
reloadFunc()
level.Debug(logger).Log("msg", "configuration reloaded after debouncing")
})
reloadTimer.Stop()
}
defer watcher.Close()
for {
Expand Down
10 changes: 9 additions & 1 deletion pkg/extkingpin/path_content_reloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ func TestPathContentReloader(t *testing.T) {
testutil.Ok(t, pathContent.Rewrite([]byte("test modified again")))
},
},
wantReloads: 1,
wantReloads: 2,
},
{
name: "Chmod doesn't trigger reload",
args: args{
runSteps: func(t *testing.T, testFile string, pathContent *staticPathContent) {
testutil.Ok(t, os.Chmod(testFile, 0777))
testutil.Ok(t, os.Chmod(testFile, 0666))
testutil.Ok(t, os.Chmod(testFile, 0777))
},
},
wantReloads: 0,
Expand All @@ -79,7 +81,9 @@ func TestPathContentReloader(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
testFile := path.Join(t.TempDir(), "test")
testutil.Ok(t, os.WriteFile(testFile, []byte("test"), 0666))
pathContent, err := NewStaticPathContent(testFile)
Expand All @@ -98,6 +102,10 @@ func TestPathContentReloader(t *testing.T) {
testutil.Ok(t, err)

tt.args.runSteps(t, testFile, pathContent)
if tt.wantReloads == 0 {
// Give things a little time to sync. The fs watcher events are heavily async and could be delayed.
time.Sleep(1 * time.Second)
}
wg.Wait()
testutil.Equals(t, tt.wantReloads, reloadCount)
})
Expand Down

0 comments on commit d3d658c

Please sign in to comment.