google / google/cadvisor

Track effective limits from parent cgroups

Open
#3,682 1 comment 0 reactions 0 assignees View on GitHub
lifecycle/stale
Dominant language
Go
Stars
19.4k
Forks
2.5k
Avg merge
9h 7m
Merged PRs (30d)
1

Description

In the system I use Docker containers are spawned in nested cgroups so the effective limit is actually at a higher level. Determining the effective limits would be more useful for that use case.

Example script to setup:
```
#!/bin/bash
set -e

# Parent cgroup path
PARENT_CG="/sys/fs/cgroup/job-1.slice"

# Create and apply limits
sudo mkdir -p "$PARENT_CG"
echo "200000 100000" | sudo tee "$PARENT_CG/cpu.max" > /dev/null
echo $((1024 * 1024 * 1024)) | sudo tee "$PARENT_CG/memory.max" > /dev/null

# Run container with systemd-compatible cgroup parent
CONTAINER_ID=$(docker run -d --rm --cgroup-parent="job-1.slice" busybox sleep 3600)
```

Cadvisor example output:

```
# TYPE container_spec_cpu_quota gauge
container_spec_cpu_quota{id="/job-1.slice",image="",name=""} 200000

container_spec_memory_limit_bytes{id="/job-1.slice",image="",name=""} 1.073741824e+09
container_spec_memory_limit_bytes{id="/job.slice/job-1.slice",image="",name=""} 0
container_spec_memory_limit_bytes{id="/job.slice/job-1.slice/docker-6fa8b18c1a826f151fb7b5accb1167f0a38a333c1f37028ecf31fb3c3362b8a9.scope",image="busybox",name="sharp_khorana"} 0
```

Note how the limit at the bottom isn't showing up as non-0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.