Skip to content

Prevent cilium-dbg from panicing when /sys is not mounted#41287

Merged
joestringer merged 1 commit intomainfrom
pr/HadrienPatte/possible-cpu
Aug 20, 2025
Merged

Prevent cilium-dbg from panicing when /sys is not mounted#41287
joestringer merged 1 commit intomainfrom
pr/HadrienPatte/possible-cpu

Conversation

@HadrienPatte
Copy link
Copy Markdown
Member

See #41286 for why is is an issue.

This PR removes the global nCPU variable from the pkg/maps/policymap package and replaces usage of ebpf.MustPossibleCPU with 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 so there's no overhead to calling it multiple times.

Fixes: #41286

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>
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Aug 19, 2025
@HadrienPatte
Copy link
Copy Markdown
Member Author

/test

@HadrienPatte HadrienPatte marked this pull request as ready for review August 19, 2025 23:31
@HadrienPatte HadrienPatte requested a review from a team as a code owner August 19, 2025 23:31
@HadrienPatte HadrienPatte requested a review from jrife August 19, 2025 23:31
@joestringer joestringer added release-note/misc This PR makes changes that have no direct user impact. needs-backport/1.18 This PR / issue needs backporting to the v1.18 branch labels Aug 20, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Aug 20, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Aug 20, 2025
Copy link
Copy Markdown
Contributor

@jrife jrife left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we just make nCPU a property of StatsMap instead of invoking possibleCPU in two places?

@HadrienPatte
Copy link
Copy Markdown
Member Author

nit: should we just make nCPU a property of StatsMap instead of invoking possibleCPU in two places?

There are already two separate places where we create a StatsMap (1, 2) so there'd still be two calls to possibleCPU

@joestringer joestringer added this pull request to the merge queue Aug 20, 2025
Merged via the queue into main with commit f180e6e Aug 20, 2025
439 of 446 checks passed
@joestringer joestringer deleted the pr/HadrienPatte/possible-cpu branch August 20, 2025 22:16
@pippolo84 pippolo84 mentioned this pull request Aug 25, 2025
17 tasks
@pippolo84 pippolo84 added backport-pending/1.18 The backport for Cilium 1.18.x for this PR is in progress. and removed needs-backport/1.18 This PR / issue needs backporting to the v1.18 branch labels Aug 25, 2025
@github-actions github-actions bot added backport-done/1.18 The backport for Cilium 1.18.x for this PR is done. and removed backport-pending/1.18 The backport for Cilium 1.18.x for this PR is in progress. labels Sep 1, 2025
@cilium-release-bot cilium-release-bot bot moved this to Released in cilium v1.19.0 Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-done/1.18 The backport for Cilium 1.18.x for this PR is done. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.

Projects

No open projects
Status: Released

Development

Successfully merging this pull request may close these issues.

cilium 1.18 image fails to build on rootless buildkit

4 participants