net_cls cgroup mounting
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- go, linux
- Domain
- operating-systems
Research direction
Start at cgroup1.NewNetCls and netclsController.Create, then trace how the net_cls controller path is prepared and where Create writes net_cls.classid. The issue is complete when the package's mounting behavior is decided and the requested create/classid flow is covered by tests or documented as unsupported.
Written by the indexing model from the issue text.
Description
Hello,
this code is not working
package main
import (
"github.com/containerd/cgroups/v3/cgroup1"
"github.com/opencontainers/runtime-spec/specs-go"
)
func uint32Ptr(v uint32) *uint32 {
return &v
}
func main() {
netClsController := cgroup1.NewNetCls("/sys/fs/cgroup")
err := netClsController.Create("foobar", &specs.LinuxResources{
Network: &specs.LinuxNetwork{
ClassID: uint32Ptr(0x00100010), //10:10
},
})
if err != nil {
panic(err)
}
}
but I think is equivalent of this:
mkdir /sys/fs/cgroup/net_cls
#mount -t cgroup -onet_cls net_cls /sys/fs/cgroup/net_cls
mkdir /sys/fs/cgroup/net_cls/foobar
echo 0x100010 > /sys/fs/cgroup/net_cls/foobar/net_cls.classid
except mounting part. We need mounting to get net_cls cgroup and to put classid into net_cls.classid.
I could not figure out if the package supports mounting, but if so, then how to force it to do that? If not, then I think it's an issue because Create creates and writes to net_cls.classid file so there is no place to put own mounting code between NewNetCls and Create.
To make Create work, the code should look something like this:
func (n *netclsController) Create(path string, resources *specs.LinuxResources) error {
if err := os.MkdirAll(path, defaultDirPerm); err != nil {
return err
}
if err := syscall.Mount("cgroup", n.root, "cgroup", 0, NetCls); err != nil {
if !errors.Is(err, syscall.EBUSY) { //could be already mounted and it's ok
// some other error
return err
}
}
if resources.Network != nil && resources.Network.ClassID != nil && *resources.Network.ClassID > 0 {
return os.WriteFile(
filepath.Join(n.Path(path), "net_cls.classid"),
[]byte(strconv.FormatUint(uint64(*resources.Network.ClassID), 10)),
defaultFilePerm,
)
}
return nil
}
version: github.com/containerd/cgroups/v3 v3.0.2
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 255
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from containerd/cgroups
-
cgroup v1 blkio parser aborts on "(unknown)" device rows, causing all container stats to failPossibly taken @ShravanthReddy claimed this 94 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 72/100
containerd/cgroups#393 ·
-
Add inspection for cgroup v2 CPU quota and periodPossibly taken @linrl3 claimed this 41 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
containerd/cgroups#377 ·
-
support filter subsystem on `cgroup.Stat()` functionPossibly taken @linrl3 claimed this 41 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
containerd/cgroups#370 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
containerd/cgroups#364 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
containerd/cgroups#328 · 1 comment ·
All issues in containerd/cgroups
Similar issues
-
P3 tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
kind/feature needs-triage priority/unprioritized
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NVIDIA/k8s-test-infra#1504 ·
Maintainers usually reply within 1 day
-
Area/Infrastructure Aspect/Infra Resources Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/agent-manager#2717 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
open-policy-agent/opa#9685 · 1 comment ·
Maintainers usually reply within 1 day