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: improve detection of directory changes #3136

Merged
merged 2 commits into from
Sep 10, 2020

Conversation

simonpasquier
Copy link
Contributor

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

When watching for changes in directories, the reloader used to rely only
on the watch interval and not on the inotify events. This commit implements
a more efficient detection of changes for watched directories.

The change also adds a new DelayInterval option that allows to delay
the config reload after no additional event are received.

Finally a new metric,
thanos_sidecar_reloader_config_apply_operations_total, is added and
thanos_sidecar_reloader_config_apply_errors_total has been renamed
to thanos_sidecar_reloader_config_apply_operations_failed_total for
consistency.

Verification

I've modified the unit test to validate that the reloader reacts on file changes (without the periodic watch). I've added a unit test to validate that the reloader's periodic watch detects a change in case it hasn't been caught by fsnotify.

I've also included this PR in prometheus-operator/prometheus-operator#3457 which is the change that triggered this PR.

@kakkoyun
Copy link
Member

kakkoyun commented Sep 9, 2020

@simonpasquier will this have any effect on falky reloader tests #2622?

Also e2e tests are failing.

@simonpasquier
Copy link
Contributor Author

Kemal, thanks for pointing the issue, I'll look into it.

@simonpasquier simonpasquier force-pushed the improve-reloader-for-dirs branch 2 times, most recently from 48a0ad0 to ac8ecd2 Compare September 9, 2020 14:26
When watching for changes in directories, the reloader used to rely only
on the watch interval and not the inotify events. This commit implements
a more efficient detection of changes for watched directories.

The change also adds a new `DelayInterval` option that allows to delay
the config reload after no additional event are received.

Finally a new metric,
`thanos_sidecar_reloader_config_apply_operations_total`, is added and
`thanos_sidecar_reloader_config_apply_errors_total` has been renamed
to `thanos_sidecar_reloader_config_apply_operations_failed_total` for
consistency.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

Amazing work. LGTM AFAICT.

pkg/reloader/reloader.go Outdated Show resolved Hide resolved
pkg/reloader/reloader.go Show resolved Hide resolved
pkg/reloader/reloader.go Outdated Show resolved Hide resolved
@kakkoyun
Copy link
Member

kakkoyun commented Sep 9, 2020

Let's have another pair of eyes before we merge this. cc @thanos-io/thanos-maintainers

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier
Copy link
Contributor Author

prometheus-operator/prometheus-operator#3457 is the prometheus-operator PR including this change.

I'm not sure that this PR will help to solve #2622. @kakkoyun do you have a recent CI failure for this? I've run the unit tests several times (>100) on my machine with -race -cpu 2 and all passed (both on master and with the PR branch).

@kakkoyun
Copy link
Member

Thanks a lot for addressing issues @simonpasquier 💜 The flakiness happens on a single core and relatively slow CPU setups (such as CI). It's ok, it's not our priority for this PR. Let's see if it helps after merging this.

Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

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

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants