From 273f7142b641a091a0b259c3b50d7134c9ab995d Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:26:17 +0200 Subject: [PATCH 1/7] Fix and improve PathContentReloader tests Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- pkg/extkingpin/path_content_reloader.go | 1 + pkg/extkingpin/path_content_reloader_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/extkingpin/path_content_reloader.go b/pkg/extkingpin/path_content_reloader.go index 68c2cd252c..6979424a83 100644 --- a/pkg/extkingpin/path_content_reloader.go +++ b/pkg/extkingpin/path_content_reloader.go @@ -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 { diff --git a/pkg/extkingpin/path_content_reloader_test.go b/pkg/extkingpin/path_content_reloader_test.go index 84416be082..992168a501 100644 --- a/pkg/extkingpin/path_content_reloader_test.go +++ b/pkg/extkingpin/path_content_reloader_test.go @@ -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, @@ -98,6 +100,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 async. The fs watcher events are heavily async and could be delayed. + time.Sleep(1 * time.Second) + } wg.Wait() testutil.Equals(t, tt.wantReloads, reloadCount) }) From 5b89be6b70b6456212acf53056119e1b79f7176b Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:30:14 +0200 Subject: [PATCH 2/7] Run tests in parallel Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- pkg/extkingpin/path_content_reloader_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/extkingpin/path_content_reloader_test.go b/pkg/extkingpin/path_content_reloader_test.go index 992168a501..730896309c 100644 --- a/pkg/extkingpin/path_content_reloader_test.go +++ b/pkg/extkingpin/path_content_reloader_test.go @@ -82,6 +82,7 @@ func TestPathContentReloader(t *testing.T) { } for _, tt := range tests { 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) From 19c5d18dec0b7a7d0bb58690e55bb4943345cf30 Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:38:00 +0200 Subject: [PATCH 3/7] Add changelog entry Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee22ef45ca..d4e2db717b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6420](https://github.com/thanos-io/thanos/pull/6420) Index Cache: Cache expanded postings. ### Fixed +- [#6496](https://github.com/thanos-io/thanos/pull/6496): *: Remove unnecessary configuration reload from `ContentPathReloader` and improve its tests. - [#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. - [#6171](https://github.com/thanos-io/thanos/pull/6171) Store: fix error handling on limits. From 097229ed89f93481d538618bc796b3fc45a92319 Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:50:54 +0200 Subject: [PATCH 4/7] Fix table tests Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- pkg/extkingpin/path_content_reloader_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/extkingpin/path_content_reloader_test.go b/pkg/extkingpin/path_content_reloader_test.go index 730896309c..338446010e 100644 --- a/pkg/extkingpin/path_content_reloader_test.go +++ b/pkg/extkingpin/path_content_reloader_test.go @@ -81,6 +81,7 @@ 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") From 9a5705dfbe239170eaa8066410985f4c9f85cd9b Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:51:56 +0200 Subject: [PATCH 5/7] Fix typo Co-authored-by: Filip Petkovski Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- pkg/extkingpin/path_content_reloader_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/extkingpin/path_content_reloader_test.go b/pkg/extkingpin/path_content_reloader_test.go index 338446010e..7ab9a93b9f 100644 --- a/pkg/extkingpin/path_content_reloader_test.go +++ b/pkg/extkingpin/path_content_reloader_test.go @@ -103,7 +103,7 @@ func TestPathContentReloader(t *testing.T) { tt.args.runSteps(t, testFile, pathContent) if tt.wantReloads == 0 { - // Give things a little time to async. The fs watcher events are heavily async and could be delayed. + // 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() From b7028c61caa903a879696d9857445fe8bf22949a Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:36:08 +0200 Subject: [PATCH 6/7] Rerun CI Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> From 47d711bc1061e75a39bda222d9f92c3c4e0c8b76 Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:50:54 +0200 Subject: [PATCH 7/7] Rerun CI Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com>