Prevent cilium-dbg from panicing when /sys is not mounted#41287
Merged
joestringer merged 1 commit intomainfrom Aug 20, 2025
Merged
Prevent cilium-dbg from panicing when /sys is not mounted#41287joestringer merged 1 commit intomainfrom
cilium-dbg from panicing when /sys is not mounted#41287joestringer merged 1 commit intomainfrom
Conversation
This PR removes the global `nCPU` variable from the `pkg/maps/policymap` package and replaces usage of [`ebpf.MustPossibleCPU`](https://pkg.go.dev/github.com/cilium/ebpf#MustPossibleCPU) with [`ebpf.PossibleCPU`](https://pkg.go.dev/github.com/cilium/ebpf#PossibleCPU) by logging the error in case of failure and assuming a single CPU is available. Note: the underlying implementation of [`ebpf.PossibleCPU`] uses [`sync.OnceValues`](https://github.com/cilium/ebpf/blob/ae226118949d4e3de64520195b66a09591116ea0/cpu_other.go#L11-L13) so there's no overhead to calling it multiple times. Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
Member
Author
|
/test |
jrife
approved these changes
Aug 20, 2025
jrife
reviewed
Aug 20, 2025
Contributor
jrife
left a comment
There was a problem hiding this comment.
nit: should we just make nCPU a property of StatsMap instead of invoking possibleCPU in two places?
Member
Author
17 tasks
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.
See #41286 for why is is an issue.
This PR removes the global
nCPUvariable from thepkg/maps/policymappackage and replaces usage ofebpf.MustPossibleCPUwithebpf.PossibleCPUby logging the error in case of failure and assuming a single CPU is available.Note: the underlying implementation of
ebpf.PossibleCPUusessync.OnceValuesso there's no overhead to calling it multiple times.Fixes: #41286