fix: host filter accepts all and comma lists; hub no longer drops traefik lines after a copytruncate rotation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19afd221e2
commit
7b90d9e40f
15 files changed
+329
-85
No files matched your search
@@ -82,3 +82,13 @@ func TestProbeSourceMissingIsWaiting(t *testing.T) {
|
||||
}
|
||||
_ = time.Now
|
||||
}
|
||||
|
||||
func TestSameHeadCopytruncate(t *testing.T) {
|
||||
old := store.Offset{Inode: 7, Offset: 900, FP: 111, FPLen: 64}
|
||||
if !sameHead(old, store.Offset{Inode: 7, Offset: 500, FP: 111, FPLen: 64}) {
|
||||
t.Fatal("same generation must be a duplicate")
|
||||
}
|
||||
if sameHead(old, store.Offset{Inode: 7, Offset: 500, FP: 222, FPLen: 64}) {
|
||||
t.Fatal("truncated and regrown file must not be a duplicate")
|
||||
}
|
||||
}
|
||||
+14
-1
@@ -225,7 +225,7 @@ func (r *Runner) Feed(src string, text []byte, end store.Offset) bool {
|
||||
|
||||
func (r *Runner) feedLocked(src string, text []byte, end store.Offset) bool {
|
||||
name := runnerSource(src)
|
||||
if saved, ok := r.remote[name]; ok && end.Inode == saved.Inode && end.Offset <= saved.Offset {
|
||||
if saved, ok := r.remote[name]; ok && end.Inode == saved.Inode && end.Offset <= saved.Offset && sameHead(saved, end) {
|
||||
return false
|
||||
}
|
||||
if src == wire.SrcEgress {
|
||||
@@ -243,6 +243,19 @@ func (r *Runner) feedLocked(src string, text []byte, end store.Offset) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// sameHead reports whether two positions of one inode belong to the same file
|
||||
// generation. A copytruncate rotation (Traefik's log) keeps the inode and
|
||||
// restarts the offsets at 0: without comparing the head fingerprint every new
|
||||
// line below the old high-water mark would be taken for a duplicate and lost
|
||||
// until the file regrew past it. Fingerprints of different lengths cannot be
|
||||
// compared and count as the same file.
|
||||
func sameHead(a, b store.Offset) bool {
|
||||
if a.FPLen > 0 && a.FPLen == b.FPLen {
|
||||
return a.FP == b.FP
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ApplyBatch applies the lines of a batch under the commit mutex.
|
||||
func (r *Runner) ApplyBatch(lines []wire.Line) (accepted, dup int) {
|
||||
r.mu.Lock()
|
||||
|
||||
Reference in new issue
Block a user