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 <[email protected]>
  • Loading branch information
ashie committed Aug 26, 2021
1 parent 5b3dd1c commit be2118e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
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 be2118e

Please sign in to comment.