fix(bpf) Initialize cilium_percpu_trace_id map via Hive Start hook#41886
Merged
julianwiedmann merged 1 commit intocilium:mainfrom Oct 21, 2025
Merged
fix(bpf) Initialize cilium_percpu_trace_id map via Hive Start hook#41886julianwiedmann merged 1 commit intocilium:mainfrom
julianwiedmann merged 1 commit intocilium:mainfrom
Conversation
This commit resolves a rare concurrency flake observed in CI during agent startup when loading BPF collections. The `cilium_percpu_trace_id` map is defined with `LIBBPF_PIN_BY_NAME`, which means it must be initialized and pinned to the BPF filesystem only once. Previously, this map was created as part of the generic BPF collection loading mechanism, which could execute concurrently across multiple components during agent initialization. This led to a race condition. - The first thread successfully creates and **pins** the map (`/sys/fs/bpf/...`). - Subsequent concurrent threads fail when trying to **re-pin** the map, resulting in the `file exists` error and agent failure. This fix: - moves the map initialization to a Hive start hook - adds testing for the new initialization Signed-off-by: Ben Bigdelle <[email protected]>
39c203f to
13b9a11
Compare
Member
|
/test |
gentoo-root
approved these changes
Oct 20, 2025
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.
Description
This PR resolves a race condition during agent startup that caused CI flakes when loading the cilium_percpu_trace_id BPF map.
As noted by this #41306 (comment), the original error seen in logs was:
error="loading eBPF collection into the kernel: map cilium_percpu_trace_id: pin map to /sys/fs/bpf/tc/globals/cilium_percpu_trace_id: file exists"Cause
The cilium_percpu_trace_id map is defined with the LIBBPF_PIN_BY_NAME flag, making it a globally shared, pinned map, so because multiple datapath components start and load BPF programs concurrently during agent initialization, multiple goroutines were attempting to create/pin this BPF map simultaneously. The first attempt works, but all other attempts fail with the message linked above.
Fix
The map's initializeion is now done via Hive injection: A dedicated iptrace.Cell is registered in daemon/cmd/cells.go. This uses the OnStart hook to call
OpenOrCreate()for the cilium_percpu_trace_id map.Fixes: #42125