add cgroup_namespace option to addon configuration
#3203
Replies: 2 comments 6 replies
-
|
The technical case is solid, but I'm wondering about the practical fit for Home Assistant's target audience. eBPF cgroup programs are a powerful tool, but writing and maintaining them is firmly in network/systems engineer territory - not something a typical home user would ever interact with, configure, or even be aware of. Home Assistant's strength is making complex home automation accessible; addons that require eBPF expertise to develop or debug feel more at home in an enterprise or datacenter context. |
Beta Was this translation helpful? Give feedback.
-
|
👋 hi there - thank you @eliottness for filling this feature request; I was the one who raised this on the forum ~a year ago: https://community.home-assistant.io/t/mount-hosts-proc-sys-into-add-on-container/848705 To give some concrete reasons why I'd like better observability of my haos instance:
I am super biased here - I work on Grafana, Prometheus etc - but I feel like having better support for observability & telemetry would make is easier to debug issues with home assistant. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your core improvement
Add a
cgroup_namespaceoption to apps config for the supervisor to pickup, mapping to Docker'scgroupns_modeparameter:The Supervisor already exposes the other namespace options:
host_network--network=hosthost_pid--pid=hosthost_ipc--ipc=hosthost_uts--uts=hostcgroup_namespace--cgroupns=host(proposed)Frontend side this may require adapting the security rating of an app.
Values
privateon cgroup v2,hoston cgroup v1)hostprivateThe Docker Python SDK already supports
cgroupns_mode(API 1.41 / Docker CE 20.10)Current limitations
On cgroup v2 hosts, Docker defaults to
--cgroupns=privatefor containers. The Supervisor doesn't override this, so addon containers get their own cgroup namespace. This is fine for most addons, but it breaks one specific thing: BPF programs attached to cgroup hooks only affect processes inside the addon container, not host processes or other containers.The kernel blocks
setns()from a child cgroup namespace to a parent — by design, not a bug. So there's no workaround from inside a running container. The container has to be started with--cgroupns=host.In Kubernetes, privileged pods get
--cgroupns=hostautomatically via the container runtime. Docker doesn't do this, even with--privileged.Use case
When building an addon that uses eBPF for network-level features. The BPF programs compile, load, and attach correctly inside the container. But because the container has a private cgroup namespace, the programs only intercept syscalls from processes inside the addon itself — not from other addons or the host.
I tried every workaround I could think of:
nsenter --cgroup=/proc/1/ns/cgroup— Permission denied (kernel blocks child-to-parent setns)mount --bind /proc/1/root/sys/fs/cgroup— fails/proc/1/root/sys/fs/cgroup— attach still resolves to the container's cgroupNone of them work because the kernel enforces cgroup namespace isolation at the syscall level. The only fix is
--cgroupns=hostat container start time.Technical benefits
This matters for addons that need to do system-level monitoring or networking. For example, any addon that attaches eBPF programs to cgroup hooks for traffic accounting, resource monitoring, or network interception will only see its own container's traffic — not the host's or other addons'. There have been community discussions about addons needing deeper system access, and the cgroup namespace is one of the remaining gaps.
Additional context
Beta Was this translation helpful? Give feedback.
All reactions