fix: head fingerprint covers the whole first line; hub no longer drops traefik generations whose first 64 bytes repeat (2.2.1)
CI / Format and vet (push) Successful in 1m15s
CI / Dependency audit (push) Successful in 36s
CI / Tests (Linux, race detector) (push) Successful in 2m7s
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Build hub image (amd64) (push) Skipped
Release / Build probe image (amd64) (push) Skipped
Release / Build hub image (arm64) (push) Skipped
Release / Build probe image (arm64) (push) Skipped
Release / Publish tags (hub) (push) Successful in 18s
Release / Publish tags (probe) (push) Successful in 18s
Release / Gitea release (push) Successful in 4s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-16 20:57:25 -03:00
1 parent c2bee81bc1
commit 87178dbc94
7 files changed
+43 -6

No files matched your search

+4 -1
View File
@@ -28,7 +28,10 @@ type Pos struct {
FPLen int
}
const fpMax = 64
// fpMax covers a whole first line: Traefik's first 64 bytes (client address and
// port of a keep-alive connection) repeat across rotations, so a short head
// cannot tell two generations of the file apart.
const fpMax = 1024
func fingerprint(b []byte) uint64 {
h := uint64(14695981039346656037)
+13
View File
@@ -155,3 +155,16 @@ func TestStalePosAndBackups(t *testing.T) {
t.Fatalf("%v", got)
}
}
// Traefik: the first 64 bytes of each rotated generation were identical (same
// keep-alive client address and port), so the head must cover the whole line.
func TestHeadCoversFirstLine(t *testing.T) {
a := []byte(`{"ClientAddr":"195.200.0.252:34352","ClientHost":"195.200.0.252","StartUTC":"2026-11-16T21:06:20.1Z"}` + "\n")
b := []byte(`{"ClientAddr":"195.200.0.252:34352","ClientHost":"195.200.0.252","StartUTC":"2026-11-16T22:48:21.7Z"}` + "\n")
if fingerprint(a[:64]) != fingerprint(b[:64]) {
t.Fatal("fixture: the first 64 bytes should collide")
}
if fpMax < len(a) || fingerprint(a) == fingerprint(b) {
t.Fatal("head fingerprint must tell the two generations apart")
}
}