Repository navigation
LOC-justify cuts: ENI filter via slices and one shutdown drain path - #30
Merged
Merged
Conversation
Run's shutdown select had two graceful arms: the ctx arm took lifecycleMu before returning, the control-server arm did not. httpx.Run returns nil once its ctx is done, so on SIGTERM both arms could be ready and a scheduler-timed wake let the process exit without the drain that 5ac5729 installed. The arms now share one tail; the control error is reported as "control server: %w" and the linkIndex field drops a comment that restated its use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cuts from the 2026-09-21 LOC-justify pass over the five K8s repos, applied after the report-only round. One commit per row, zero comment lines added, no test edited.
Commits
d7bd0cfselectReusableENIs filters through slices.DeleteFuncslices.DeleteFunc(slices.Clone(enis), …); the clone keeps the caller's slice intact, the[:min(len, count)]tail is unchanged0b64250every graceful DHCP shutdown takes the lifecycle drainRun's<-ctx.Done()arm tooklifecycleMubefore returning, but the<-controlErrCharm with a nil error and a canceled ctx returned without it.httpx.Runreturns nil after a ctx-driven shutdown, so on SIGTERM both arms can be ready and a queued handler could start a transaction the process cannot finish. The select now folds into one tail: close the listener, cancel the run ctx, drain the control error if it is still owed, then take the drain lock on every clean exit. Error texts becomecontrol server: %wandcontrol server: stopped unexpectedly. ThelinkIndextrailing comment restated the fieldNet: −8 prod lines, comment lines +1/−1 (the drain comment moved with the lock).
The shutdown fold changes an edge behavior and is labelled
fix:; no test drivesRun(Linux-gated, real sockets), so the proof is the linux container run below plus the narrowed control flow.Gates
GOOS=darwinandGOOS=linuxmake lint: 0 issues / 0 issues each;make fmt-checkclean.go test -race -count=1 ./...: 7 ok.golang:1.27container with--cap-add=NET_ADMIN,go build && go vet && go test -race: 7 ok on0b64250.Codex was not run: cut PRs go without it unless asked.