Skip to content

review: batch-end quality round - #8

Merged
CMGS merged 9 commits into
mainfrom
review/audit-2026-07-23
Jul 23, 2026
Merged

review: batch-end quality round#8
CMGS merged 9 commits into
mainfrom
review/audit-2026-07-23

Conversation

@CMGS

@CMGS CMGS commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Batch-end quality round: style walkthrough, comment budget, simplify lenses, and a loc-justify pass with adversarial verification of every candidate.

Removed

  • dhcp/server.go: Server.mu and Server.stopped (12 lines). The flag is written only in the ctx.Done() case body and read only in the errCh case body of a single non-looping select, so no execution can observe its own write. Run is single-shot (srv.Run(ctx) is a direct return in cmd/daemon.go, no retry wrapper), and srv.Close() runs only in the branch that returns immediately, so the post-Close serve error is unreachable. Even when both cases are ready simultaneously and select picks errCh, stopped is false — today's behaviour already returns the wrapped error. The mutex guarded nothing shared: the metrics goroutine reads through the pool/lease locks.

Kept, after verification

  • node/iptables_linux.go: iptEnsure / iptInsert. Merging them is safe but not a simplification: it deduplicates ~6 lines of boilerplate and pays with a positional boolean at all 5 call sites, hiding the append-at-tail vs insert-at-head distinction that the surrounding comment says is correctness-relevant (DROP must precede ACCEPT).

Style and comments

  • cmp.Or replaces hand-rolled empty-string fallbacks in the GKE and Volcengine provisioners.
  • pool_test.go reuses the package's filePerm constant instead of a literal 0o644.
  • Comment budget applied; the evictedLease rationale was condensed to one line rather than dropped, since it carries the WHY (a same-MAC rebind orphans the old IP's route and pool slot).

Gates

  • GOWORK=off make lint (GOOS=linux and darwin): 0 issues
  • GOWORK=off go test -race -count=1 ./...: all packages pass
  • golangci-lint fmt --diff ./...: clean
  • go.mod / go.sum unmodified

Net: -20 prod, 0 test.

CMGS added 9 commits July 23, 2026 15:03
Drop lease.go add() comments that restate the adjacent condition.
Use cmp.Or for the primaryNIC fallback in place of the manual if-empty check.
Reuse the existing filePerm constant instead of a duplicated literal.
Remove Server.mu and Server.stopped from dhcp/server.go: the flag is
written only in the ctx.Done() branch (which returns immediately) and
read only in the errCh branch of the same non-looping select, so no
execution path can observe its own write, and Run has no retry
wrapper. Also drops the now-unused sync import.
A negative --pool-size reaches make([]string, 0, count) with a
negative capacity, which panics instead of returning a clean
validation error to the caller.
ProvisionNetwork previously created and attached enisPerNode ENIs
unconditionally on every call. A retry after a mid-provision failure
left the first batch attached and orphaned, then hit the ENI quota
and could never succeed. ensureENIs now lists what is already
attached, reuses non-primary ENIs, and only creates the shortfall;
IP assignment likewise tops up each ENI to ipsPerENI instead of
reassigning a full batch.
…e attach

An ENI created but not yet attached is invisible to the instance-filtered
list that both retry reuse and teardown rely on, so a SIGTERM in the
propagation window leaked it and its quota permanently.
@CMGS
CMGS merged commit c668398 into main Jul 23, 2026
2 checks passed
@CMGS
CMGS deleted the review/audit-2026-07-23 branch July 23, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant