The Delivery log box of every refused row said "This message never reached
the queue, so Postfix wrote no delivery lines for it" - untrue: Postfix
wrote a line for each. The owner, 2026-10-13: the box is required on every
message page. Pictured for him first (dev/shots, the refused variant of
out-message: wrong From with its queue id lines, rate-limited with the
NOQUEUE line); the variant has no mockup screen of its own - the guard ties
screens to pages, and its outline is out-message's.
- Wrong From: cleanup gives the message a queue id before the headers are
judged; the sender check reads {i} at end-of-headers and writes it on the
refused row. Its lines - stored under the id like any other's - are on the
page, but only those from 10 minutes before to 1 minute after the refusal
(store.SendLogLines for a rejected row): Postfix frees the id at once, and
a later message with it lends nothing. No mail.log fallback for a refused
row, for the same reason.
- Rate-limited and wrong client: refused at MAIL FROM, no queue id. Migration
0009 adds send_log.refusal_line; logtail.refusalLines matches smtpd's
"NOQUEUE: milter-reject: MAIL from ...; from=<...>" (not port 25's, not
CONNECT/EHLO) and store.AttachRefusalLine puts it on the newest refused row
of that sender (and login, when the line names it) within two minutes; a
line whose row is not written yet waits up to 30 s (retried at each pass).
- The page: the queue id fact says "given, the message was not queued" or
"none - refused at MAIL FROM, before one is given"; the box's caption is
"The line from mail.log for this refusal" for the latter; a row from
before says the line was not kept. LogLineLevel colours a refusal by its
reply: 5xx red, 4xx amber (IPv6 clients included). The id in the fact is
not muted as in the picture: the kit has no muted inline.
Tests: store (attach by sender, login, time; not a queued row, not one an
hour off; a refused row's lines are its own minutes); logtail (attach, wait
and retry, port 25 and other lines ignored); milter (the refused row carries
{i}); view (facts, caption, line levels); handlers (the line on the page,
the sentence without it). e2e refusals_show_postfixs_line: a client-address
refusal made there, and the pages of a wrong From, a rate-limited and a
wrong client refusal each show Postfix's line.
schema-migrations row 9, CHANGELOG [Unreleased], audit plan line ticked,
roadmap 25/62.
Evidence on the test server for this tree: make e2e exit 0 (the new case
in 5.4 s); go test ./... ok but for two schema tests, fixed after the run
(the schema at 0009) - store tests ok locally; the full run follows before
the push.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
3.0 KiB
Go
105 lines
3.0 KiB
Go
package logtail
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/mixeme/selfpost/internal/store"
|
|
)
|
|
|
|
type retentionProbeStore struct {
|
|
mu sync.Mutex
|
|
cutoff time.Time
|
|
}
|
|
|
|
func (s *retentionProbeStore) UpdateStatus(string, string, string) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
func (s *retentionProbeStore) ListQueuedOlderThan(time.Time) ([]store.QueuedDelivery, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (s *retentionProbeStore) CloseUnreported(int64) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
func (s *retentionProbeStore) AddReconcileMissed(time.Time, int64) error { return nil }
|
|
func (s *retentionProbeStore) AddReconcileClosed(time.Time, int64) error { return nil }
|
|
func (s *retentionProbeStore) AddTailerBlind(time.Time, time.Duration) error { return nil }
|
|
func (s *retentionProbeStore) CountQueuedOlderThan(time.Time) (int64, error) { return 0, nil }
|
|
func (s *retentionProbeStore) SetQueuedOverLifetime(time.Time, int64) error { return nil }
|
|
func (s *retentionProbeStore) PruneDeliveryLogDays(time.Time) error { return nil }
|
|
|
|
func (s *retentionProbeStore) DeleteSendLogBefore(cutoff time.Time) (int64, error) {
|
|
s.mu.Lock()
|
|
s.cutoff = cutoff
|
|
s.mu.Unlock()
|
|
return 0, nil
|
|
}
|
|
|
|
func (s *retentionProbeStore) InsertSendLogLines([]store.SendLogLine, bool) (int, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
func (s *retentionProbeStore) PruneSendLogLines(time.Time) (int64, error) { return 0, nil }
|
|
|
|
func (s *retentionProbeStore) LogtailState(string) (store.LogtailState, bool, error) {
|
|
return store.LogtailState{}, false, nil
|
|
}
|
|
|
|
func (s *retentionProbeStore) SaveLogtailState(string, store.LogtailState) error {
|
|
return nil
|
|
}
|
|
|
|
func (s *retentionProbeStore) lastCutoff() time.Time {
|
|
s.mu.Lock()
|
|
defer s.mu.Unlock()
|
|
return s.cutoff
|
|
}
|
|
|
|
// retentionLoop must re-read the configured window every cycle so a panel
|
|
// change takes effect without restarting the process.
|
|
func TestRetentionLoopUsesUpdatedValue(t *testing.T) {
|
|
old := retentionInterval
|
|
retentionInterval = 20 * time.Millisecond
|
|
t.Cleanup(func() { retentionInterval = old })
|
|
|
|
var days atomic.Int32
|
|
days.Store(30)
|
|
|
|
st := &retentionProbeStore{}
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
go retentionLoop(ctx, st, func() int { return int(days.Load()) })
|
|
|
|
deadline := time.Now().Add(2 * time.Second)
|
|
for time.Now().Before(deadline) {
|
|
if age := time.Since(st.lastCutoff()); age < 31*24*time.Hour && age > 29*24*time.Hour {
|
|
break
|
|
}
|
|
time.Sleep(5 * time.Millisecond)
|
|
}
|
|
if age := time.Since(st.lastCutoff()); age < 29*24*time.Hour || age > 31*24*time.Hour {
|
|
t.Fatalf("first prune cutoff age %v, want about 30 days", age)
|
|
}
|
|
|
|
days.Store(7)
|
|
deadline = time.Now().Add(2 * time.Second)
|
|
for time.Now().Before(deadline) {
|
|
if age := time.Since(st.lastCutoff()); age < 8*24*time.Hour && age > 6*24*time.Hour {
|
|
return
|
|
}
|
|
time.Sleep(5 * time.Millisecond)
|
|
}
|
|
age := time.Since(st.lastCutoff())
|
|
t.Fatalf("second prune cutoff age %v, want about 7 days", age)
|
|
}
|
|
|
|
func (s *retentionProbeStore) AttachRefusalLine(string, string, time.Time, string) (bool, error) {
|
|
return true, nil
|
|
}
|