Skip to content

Commit 230f294

Browse files
fujimotosedsiper
authored andcommitted
in_tail: detect rotation on symlink targets
Kiichiro Okano reported that Fluent Bit keeps reading from the old file when docker rotates a log file (in issue 1712). This bug occurs because Fluent Bit only checks the identify of the source file (if it is a symlink), and never check if the target file is the same as before. For this reason, Fluent Bit would keep the file handler to the old target file even after the symlink switched to the new file. Change in_tail to check the identities of both the source file and the target file, and thus makes it aware of both rotation patterns. Signed-off-by: Fujimoto Seiji <[email protected]>
1 parent d7f4973 commit 230f294

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

plugins/in_tail/tail_file.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,12 +966,9 @@ int flb_tail_file_is_rotated(struct flb_tail_config *ctx,
966966
}
967967
else {
968968
/* The file name is there, check if the same that we have */
969-
if (st.st_ino == file->link_inode) {
970-
return FLB_FALSE;
969+
if (st.st_ino != file->link_inode) {
970+
return FLB_TRUE;
971971
}
972-
973-
/* no rotation */
974-
return FLB_TRUE;
975972
}
976973
}
977974

0 commit comments

Comments
 (0)