Fix some issue from logs, panics#212
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a production crash and several stability/observability issues in the access log and process discovery/profiling paths, including safer handling of missing HTTP/2 bodies, reduced memory retention of ELF symbols, and less noisy dropped-sample/process-exit logging.
Changes:
- Fix access log panics by making socket-detail aggregation and error paths nil-safe (HTTP/1.x + HTTP/2), and add targeted tests.
- Reduce discovery-time memory growth by avoiding retention of heavy ELF symbol data unless an actual profiling task runs.
- Aggregate dropped perf-sample warnings periodically and tune default protocol per-CPU buffer size.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tools/process/process.go | Adds SupportProfiling and changes profiling info construction behavior (affects memory/CPU tradeoffs). |
| pkg/tools/btf/lostsamples.go | New dropped-sample aggregation logic with periodic summary logging. |
| pkg/tools/btf/linker.go | Routes perf lost-sample events into the new aggregated counter instead of per-burst warns. |
| pkg/process/finders/kubernetes/process.go | Stops caching heavy profiling info on the process; adds cached boolean support check; quiets expected “process exited” connection-query errors. |
| pkg/process/finders/kubernetes/finder.go | Uses SupportProfiling() for support_ebpf_profiling property. |
| pkg/process/finders/base/tool.go | Adds a lightweight support check wrapper for discovery-time use. |
| pkg/process/api/process.go | Extends DetectedProcess interface with SupportProfiling() bool. |
| pkg/accesslog/collector/protocols/protocol.go | Makes detail aggregation treat nil buffers as absent (not incomplete) and adds DataIDRangeBounds. |
| pkg/accesslog/collector/protocols/http2.go | Guards HTTP/2 error path to avoid nil dereferences when detail ranges are absent. |
| pkg/accesslog/collector/protocols/http2_test.go | Adds tests covering nil-safe aggregation, error-path safety, and bodiless-stream reporting. |
| pkg/accesslog/collector/protocols/http1.go | Guards HTTP/1.x error path to avoid nil dereferences when detail ranges are absent. |
| configs/rover_configs.yaml | Increases protocol per-CPU buffer default; changes pprof activation default. |
| CHANGES.md | Documents crash fix and stability/observability improvements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wu-sheng
approved these changes
Jul 6, 2026
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.
Summary
This PR fixes a production crash and several stability/observability problems found by inspecting a running rover DaemonSet (repeated restarts, a growing memory footprint, and noisy logs). The changes are grouped into one crash fix plus three stability/observability improvements, all in the access log and process-discovery paths.
Motivation
While investigating a rover pod that kept restarting, the following issues were identified from the logs,
pprof, andkubectl:SIGSEGVin the access log HTTP/2 handler whenever a monitored HTTP/2 stream had no request or response body (for example aGETwith a204/304/redirect or a gRPC trailers-only response).socket_data_upload_queue full, dropped N sampleswarnings were logged on every burst, flooding the log during traffic spikes.query the process connection error: ... /proc/<pid>/net/udp: no such file or directorywarnings were produced by short-lived processes exiting between discovery and the connection query.Changes
Bug fix: HTTP/2 access log panic
AppendSocketDetailsFromBuffer: an absent (nil) buffer was treated the same as an incomplete one, and the error path then dereferenced the nil buffer to build the message, panicking.AppendSocketDetailsFromBuffernow skips a nil buffer (a legitimately absent request/response body) instead of marking the whole message incomplete; only a buffer that is present but missing some of its detail events (e.g. dropped perf samples) is treated as incomplete.HTTP2Protocol.HandleWholeStreamandHTTP1Protocol.HandleHTTPDatanow guard the error path (!allInclude || idRange == nil || len(details) == 0) and use the shared, nil-safeDataIDRangeBoundshelper so the message is built without dereferencing a possibly-nil range.Improvement: reduce memory by not retaining ELF symbols
ProfilingStat()only to set thesupport_ebpf_profilingproperty, which eagerly parsed and permanently retained the full ELF symbol tables of every discovered process.SupportProfiling()reports whether a process is profilable (has symbols and is not excluded) without retaining the parsed data, and discovery now uses it.ProfilingStat()no longer caches the heavyInfoon the process; it is built on demand by a profiling task's runner and released when the task ends, so symbols are only resident while a process is actually being profiled.Improvement: dropped perf sample observability and tuning
drain()reads and resets the counter each interval so the map does not grow unbounded.ROVER_ACCESS_LOG_PROTOCOL_ANALYZE_PER_CPU_BUFFER) is raised from400KBto1MBto absorb the observed bursts, since the agent had ample CPU/memory headroom.Improvement: quieter connection query for short-lived processes
os.ErrNotExist/no such file or directory) is now logged at debug level, since it is an expected race for ephemeral processes rather than a real error.Behavior changes worth noting
DataSize()andBufferSizeOfZerohandle nil buffers), so this only affects which streams are emitted, not stability.support_ebpf_profilingnow reflects "the executable has symbols and is not excluded" rather than "the full profiling info could be built"; the two differ only when reading/proc/<pid>/mapsfails after the symbol check passes.Tests
AppendSocketDetailsFromBuffer: nil buffer is skipped, incompleteness is propagated, an empty buffer and a buffer whose details fall outside its captured range are incomplete, and a fully-captured buffer contributes its detail.DataIDRangeBounds: returns(0, 0)for a nil range and the real bounds otherwise.HandleWholeStream: incomplete/all-nil streams return an error without panicking (reproduces the originalSIGSEGVon the pre-fix code), and a bodiless stream is reported through the queue.ParseHTTPMethod,FirstDetail, andBufferSizeOfZero: cover the default/unknown-method handling and the nil-safe helpers used by the send path.lostSampleCounter.drain: accumulates counts and resets on drain.Verification
go build ./...,go vet, and the changed-package tests pass onlinux(the eBPF packages only build on Linux).golangci-lint(the project's pinned version) reports0 issueson the changed packages.