Introduce directory watch abstraction#7307
Open
twz123 wants to merge 4 commits intok0sproject:mainfrom
Open
Conversation
Encapsulate fsnotify behind a directory-oriented watch API with a custom event model. Adapt the applier manager to use the new abstraction instead of fsnotify directly. While doing so, keep stack keys relative to the manifests bundle directory, instead of using joined paths. Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Add internal/os/watch.OnDirChange on top of watch.Dir to group accepted directory watch events into debounced change bursts and invoke a callback after a quiet period. This replaces the previous raw fsnotify plus debouncer pattern, providing a more streamlined approach that can be reused across k0s components. Use the new helper in the stack applier. Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Switch containerd drop-in watching from raw fsnotify plus Debouncer to the new way of doing it. Add the new RejectActivations predicate the drop-in watcher ignores the initial watch activation event and only restarts containerd after subsequent filesystem changes. Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Switch the OCI bundle directory watching from the old debouncer-based flow to internal/os/watch.OnDirChange. Add the new InitialDelay field to OnDirChange so that the initial timeout after activation can be shorter. Remove the now-unused debounce package. Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In preparation of #7308:
Encapsulate fsnotify behind a directory-oriented watch API with a custom event model.
Adapt the applier manager to use the new abstraction instead of fsnotify directly. While doing so, keep stack keys relative to the manifests bundle directory, instead of using joined paths.
Add a debouncing directory change watcher on top of the new watch API to group accepted directory watch events into debounced change bursts and invoke a callback after a quiet period. This replaces the previous raw fsnotify plus debouncer pattern, providing a more streamlined approach that can be reused across k0s components.
Use the directory change watcher for watching manifest stacks, containerd drop-ins and OCI image archives. Remove the now-unused debounce package.
Type of change
How Has This Been Tested?
Checklist