Commit 964ecd4
committed
main: gate AdminForward on adminEnabled + close conn cache (review)
Four findings from Claude / Codex / CodeRabbit on PR #648:
1) **P1 / Major**: AdminForward gRPC registration was gated only on
adminForwardServerDeps.readyForRegistration() (tables + roles both
non-nil), neither of which referenced *adminEnabled. A node started
with -adminEnabled=false but with admin access keys still configured
would have registered the leader-side gRPC AdminForward service and
accepted forwarded admin writes — re-exposing the table-mutation
surface a follower-direct admin call could reach. Fix: build
roleStore + connCache only when *adminEnabled. With admin disabled,
forwardDeps.roles stays nil and registerAdminForwardServer's
readyForRegistration gate skips the gRPC bind entirely.
2) **Resource leak (Claude Issue 1, CodeRabbit Minor)**: connCache was
created in startServers() but never closed. Every address dialled
accumulates an open HTTP/2 connection that is never released.
Fix: shutdown goroutine that drains the cache via Close() on
in.ctx.Done(), wired through the existing errgroup.
3) **Lint hygiene (Claude Issue 2)**: //nolint:nilnil suppresses a
linter that is not enabled in .golangci.yaml AND violates
CLAUDE.md's "Avoid //nolint — refactor instead" rule. The directive
was pure dead weight. Fix: drop the directive; the doc comment on
the function and the inline comment already explain the
nil-means-disabled contract.
4) **Coverage gap (Claude Issue 3)**: buildAdminLeaderForwarder's
nil-coordinate / nil-cache short-circuit was untested. A future
refactor that drops the guard would silently pass a nil
collaborator into buildLeaderForwarder, which would either crash
on the nil deref or build a forwarder that panics on the first
request. Fix: TestBuildAdminLeaderForwarder_NilGateReturnsNoForwarder
covers all three nil combinations + the empty-nodeID error path,
plus a happy-path companion.1 parent 19f6b70 commit 964ecd4
3 files changed
Lines changed: 94 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
654 | 654 | | |
655 | 655 | | |
656 | 656 | | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
669 | 691 | | |
670 | 692 | | |
671 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
138 | 144 | | |
139 | 145 | | |
140 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
127 | 180 | | |
128 | 181 | | |
129 | 182 | | |
| |||
0 commit comments