Skip to content

Commit

Permalink
in_tail: Keep consistency more carefully at construct_watcher
Browse files Browse the repository at this point in the history
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
  • Loading branch information
ashie committed Aug 26, 2021
1 parent 2aed6f4 commit 38d4f9f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/fluent/plugin/in_tail.rb
Expand Up @@ -407,8 +407,10 @@ def setup_watcher(target_info, pe)
def construct_watcher(target_info)
path = target_info.path

# The file might be rotated or removed after collecting paths, so check inode again here.
begin
ino = Fluent::FileWrapper.stat(path).ino
target_info.ino = ino
rescue Errno::ENOENT, Errno::EACCES
$log.warn "stat() for #{path} failed. Continuing without tailing it."
return
Expand All @@ -422,12 +424,13 @@ def construct_watcher(target_info)

begin
tw = setup_watcher(target_info, pe)
@tails[path] = tw
tw.on_notify
rescue WatcherSetupError => e
log.warn "Skip #{path} because unexpected setup error happens: #{e}"
return
end

@tails[path] = tw
tw.on_notify
end

def start_watchers(targets_info)
Expand Down

0 comments on commit 38d4f9f

Please sign in to comment.