fix(envd): log net.Connections error in port scanner and add unit tests - #3422
fix(envd): log net.Connections error in port scanner and add unit tests#3422chill-czar wants to merge 1 commit into
Conversation
a2bd81c to
400e5fe
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 400e5fedb0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| processes, err := net.Connections("tcp") | ||
| if err != nil { | ||
| if s.logger != nil { | ||
| s.logger.Error().Err(err).Msg("Failed to scan open TCP connections") | ||
| } |
There was a problem hiding this comment.
Bump envd version for the scanner behavior change
This changes envd port-forwarding behavior: when net.Connections("tcp") fails, the forwarder now preserves the previous port set instead of treating the scan as empty. packages/envd/pkg/version.go is unchanged from the parent (0.6.13), so template builds containing this fix record the same envd version as builds without it; because the API/orchestrator gate behavior on the recorded envd version, rollouts cannot distinguish sandboxes with the new scanner semantics. Please bump the envd version with this behavioral change.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Bumped envd version to 0.6.14 in packages/envd/pkg/version.go for the scanner behavioral change over upstream/main (0.6.13).
400e5fe to
85aa029
Compare
|
Hi @jakubno @ben-fornefeld, whenever you get a chance, could you please take a look at this PR? Quick summary: This fix prevents |
Closes #3421
Summary
logger *zerolog.Loggerfield toScannerand lognet.Connections("tcp")errors inpackages/envd/internal/port/scan.goScanAndBroadcastfrom signaling subscribers withnilconnection lists on scan failureNewScannerinpackages/envd/main.goto receive loggerenvdversion to0.6.14inpackages/envd/pkg/version.gopackages/envd/internal/port/scan_test.gofor scanner initialization, filtering, and prompt shutdownWhy
Currently,
ScanAndBroadcastdiscards errors returned bynet.Connections("tcp")with_. When reading/proc/net/tcpfails (e.g. transient procfs read failures or system resource exhaustion),processesisnil.ScanAndBroadcastpassesnilto subscribers, causingForwarderto assume zero TCP ports are open. As a result,Forwardermarks all active forwarded ports asDELETEand forcibly kills all active backgroundsocatforwarding processes, silently dropping user process reachability inside sandboxes. Logging the error and skipping subscriber signaling on failure preserves activesocatport forwarding until the next successful scan.Test Plan
go test -count=1 -v ./packages/envd/internal/port/...go vet ./packages/envd/internal/port/... ./packages/envd/...Destroy()inscan_test.goenvdversion to0.6.14perdocs/ARCHITECTURE.mdrequirement/cc @jakubno @dobrac @ValentaTomas @arkamar @tvi