Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic while trying to inspect cgroup #2

Closed
clebio opened this issue Feb 9, 2019 · 2 comments
Closed

Panic while trying to inspect cgroup #2

clebio opened this issue Feb 9, 2019 · 2 comments

Comments

@clebio
Copy link

clebio commented Feb 9, 2019

I'm following your walkthrough.md, using a Vagrant box, and got a panic.

Looking at the namespace,

vagrant@ubuntu-14:~$ sudo cinf --namespace 4026532177

 PID    PPID   NAME   CMD                   NTHREADS  CGROUPS                                                                                  STATE

 12397  12379  nginx  nginx: master proces  1         11:hugetlb:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1      S (sleeping)
                                                      10:perf_event:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      9:blkio:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      8:freezer:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      7:devices:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      6:memory:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      5:cpuacct:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      4:cpu:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      3:cpuset:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      2:name=systemd:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
 12434  12397  nginx  nginx: worker proces  1         11:hugetlb:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1      S (sleeping)
                                                      10:perf_event:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      9:blkio:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      8:freezer:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      7:devices:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      6:memory:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      5:cpuacct:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      4:cpu:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      3:cpuset:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1
                                                      2:name=systemd:/docker/9d46982572191c4b7f8a11598102068ce6d8fed1b09d53b742f4e0598ce614f1

Then by process ID,

vagrant@ubuntu-14:~$ sudo cinf --cgroup 12397:4

 CONTROLFILE            VALUE

 cpu.cfs_quota_us       -1
 cpu.shares             256
 cpu.stat               nr_periods 0 nr_throttled 0
                        throttled_time 0
 notify_on_release      0
 tasks                  12397 12434
 cgroup.clone_children  0
 cgroup.procs           12397 12434
 cpu.cfs_period_us      100000

And that's all as-expected. However, I didn't realize at first that I needed to supply the PID not the namespace ID, and so instead tried:

vagrant@ubuntu-14:~$ sudo cinf --cgroup 4026532177:4
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x472261]

goroutine 1 [running]:
panic(0x54f520, 0xc8200160d0)
        /usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/mhausenblas/cinf/namespaces.usage(0x7fff7662e97f, 0xa, 0x7fff7662e98a, 0x1, 0x2, 0x0, 0x0)
        /Users/mhausenblas/Dropbox/dev/work/src/github.com/mhausenblas/cinf/namespaces/namespaces.go:198 +0xb11
github.com/mhausenblas/cinf/namespaces.LookupCG(0x7fff7662e97f, 0xc)
        /Users/mhausenblas/Dropbox/dev/work/src/github.com/mhausenblas/cinf/namespaces/namespaces.go:275 +0x331
main.main()
        /Users/mhausenblas/Dropbox/dev/work/src/github.com/mhausenblas/cinf/main.go:85 +0xdf

I realize this isn't a valid cgroup identifier, 4026532177:4, however, cinf shouldn't outright crash, eh?

For context, I'm using:

vagrant@ubuntu-14:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

vagrant@ubuntu-14:~$ docker --version
Docker version 18.06.1-ce, build e68fc7a

vagrant@ubuntu-14:~$ cinf --version
     ___                    ___          ___
    /\__\                  /\  \        /\__\
   /:/  /       ___        \:\  \      /:/ _/_
  /:/  /       /\__\        \:\  \    /:/ /\__\
 /:/  /  ___  /:/__/    _____\:\  \  /:/ /:/  /
/:/__/  /\__\/::\  \   /::::::::\__\/:/_/:/  /
\:\  \ /:/  /\/\:\  \__\:\~~\~~\/__/\:\/:/  /
 \:\  /:/  /  ~~\:\/\__\\:\  \       \::/__/
  \:\/:/  /      \::/  / \:\  \       \:\  \
   \::/  /       /:/  /   \:\__\       \:\__\
    \/__/        \/__/     \/__/        \/__/

This is cinf in version 0.4.0
See also https://github.com/mhausenblas/cinf

Thanks for this awesome tool and small Go utility! It is encouraging me to dig deeper into my understanding of containers.
(updated to fix markdown escaping)

@clebio
Copy link
Author

clebio commented Feb 9, 2019

Hmm, I guess it's just printing the error. Ok.
https://github.com/mhausenblas/cinf/blob/master/namespaces/namespaces.go#L293

@mhausenblas
Copy link
Owner

Thanks @clebio and will have a look ASAP.

ms140569 added a commit to ms140569/cinf that referenced this issue May 11, 2020
Signed-off-by: Matthias Schmidt <matthias.schmidt@gmail.com>
mhausenblas added a commit that referenced this issue May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants