Skip to content

Commit

Permalink
[chore][pkg/stanza] Flatten handling of lost files (open-telemetry#27454
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski authored and jmsnll committed Nov 12, 2023
1 parent 0c7c55c commit bf861b0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pkg/stanza/fileconsumer/roller_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ OUTER:
if newReader.Fingerprint.StartsWith(oldReader.Fingerprint) {
continue OUTER
}
if oldReader.FileName == newReader.FileName {
// At this point, we know that the file has been rotated. However, we do not know
// if it was moved or truncated. If truncated, then both handles point to the same
// file, in which case we should only read from it using the new reader. We can use
// the ValidateOrClose method to establish that the file has not been truncated.
if !oldReader.ValidateOrClose() {
continue OUTER
}

if oldReader.FileName != newReader.FileName {
continue
}

// At this point, we know that the file has been rotated. However, we do not know
// if it was moved or truncated. If truncated, then both handles point to the same
// file, in which case we should only read from it using the new reader. We can use
// the ValidateOrClose method to establish that the file has not been truncated.
if !oldReader.ValidateOrClose() {
continue OUTER
}
}
lostReaders = append(lostReaders, oldReader)
Expand Down

0 comments on commit bf861b0

Please sign in to comment.