Skip to content

Commit

Permalink
update state file permissions to match ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Huynh committed Apr 29, 2022
1 parent ce7b1b1 commit 7cac8c1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/inputs/logfile/logfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func TestLogsFileRecreate(t *testing.T) {
defer os.Remove(stateDir)

stateFileName := filepath.Join(stateDir, escapeFilePath(tmpfile.Name()))
stateFile, err := os.OpenFile(stateFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
stateFile, err := os.OpenFile(stateFileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
require.NoError(t, err)
_, err = stateFile.WriteString("10")
defer os.Remove(stateFileName)
Expand Down
2 changes: 0 additions & 2 deletions plugins/inputs/logfile/tailersrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ func (ts *tailerSrc) runSaveState() {
if offset == lastSavedOffset {
continue
}
log.Printf("E! [logfile] saving to state file because of ticker")
err := ts.saveState(offset.offset)
if err != nil {
log.Printf("E! [logfile] Error happened when saving file state %s to file state folder %s: %v", ts.tailer.Filename, ts.stateFilePath, err)
Expand All @@ -328,7 +327,6 @@ func (ts *tailerSrc) runSaveState() {
log.Printf("E! [logfile] failed to delete state file %s", ts.stateFilePath)
return
case <-ts.done:
log.Printf("E! [logfile] saving to state file because channel closed")
err := ts.saveState(offset.offset)
if err != nil {
log.Printf("E! [logfile] Error happened during final file state saving of logfile %s to file state folder %s, duplicate log maybe sent at next start: %v", ts.tailer.Filename, ts.stateFilePath, err)
Expand Down

0 comments on commit 7cac8c1

Please sign in to comment.