Skip to content

Commit 644e428

Browse files
committed
docs(raftengine): PR783 r2 claude nits — fix stale struct-comment + cleaner errors.Newf wrap
Claude r2 on PR #783 flagged two cosmetic items: ## Issue A (blocking per "before merge") — stale struct comment The encryptionScanner struct comment said "constructed once per Engine and embedded into the engine struct" but Engine.EncryptionScanner() allocates a fresh value on each call (intentionally — the scanner is stateless). Updated to "wraps the engine's *MemoryStorage; a fresh value is constructed per Engine.EncryptionScanner() call (cheap — no internal state)" to match the implementation. ## Issue B (nit) — awkward errors.Wrapf(errors.New(...)) The no-progress fail-closed path used errors.Wrapf(errors.New("no progress"), "encryption scanner: ...") which reads as "encryption scanner: ...: no progress" — making the sentinel look like the cause rather than just the description. There's no caller that needs to errors.Is on the "no progress" sentinel, so collapsing to errors.WithStack(errors.Newf(...)) is cleaner. Matches the existing pattern at internal/admin/config.go:109+ for newly- constructed errors that satisfy wrapcheck. ## Verification - go test -race -timeout=60s ./internal/raftengine/etcd/... — PASS - golangci-lint run ./internal/raftengine/etcd/... — 0 issues
1 parent cee20b3 commit 644e428

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

internal/raftengine/etcd/encryption_scanner.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import (
2121
const scanMaxBytes uint64 = 64 << 20 // 64 MiB
2222

2323
// encryptionScanner implements encryption.EncryptionRelevantScanner
24-
// against the engine's in-memory raft storage. It is constructed
25-
// once per Engine and embedded into the engine struct; callers get
26-
// access to it via Engine.EncryptionScanner().
24+
// against the engine's in-memory raft storage. It wraps the
25+
// engine's *MemoryStorage; a fresh value is constructed per
26+
// Engine.EncryptionScanner() call (cheap — no internal state).
27+
// Callers get access to it via Engine.EncryptionScanner().
2728
//
2829
// The scan walks raftpb.Entry rows in (startExclusive, endInclusive]
2930
// via etcdraft.MemoryStorage.Entries(lo, hi, maxSize), filters out
@@ -85,9 +86,9 @@ func (s *encryptionScanner) HasEncryptionRelevantEntryInRange(startExclusive, en
8586
// we surface it as a scanner error. The caller routes
8687
// scanner errors as a refusal distinct from
8788
// ErrSidecarBehindRaftLog.
88-
return false, errors.Wrapf(errors.New("no progress"),
89+
return false, errors.WithStack(errors.Newf(
8990
"encryption scanner: Entries(cursor=%d, hi=%d) returned no entries and no error (unscanned gap)",
90-
cursor, hi)
91+
cursor, hi))
9192
}
9293
for _, ent := range batch {
9394
if isEncryptionRelevantEntry(ent) {

0 commit comments

Comments
 (0)