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

plugins/linux/virtualization: if lxc and docker are on the same host, it can't detect lxc #833

Closed
goacid opened this issue Jun 17, 2016 · 6 comments

Comments

@goacid
Copy link

goacid commented Jun 17, 2016

Description

Phys Host : ubuntu 16.04 LTS with docker engine 1.11 and lxc 2.0.1 installed.
LXC containers are ubuntu 14.04 with chef (from 11 to latest),which embeded ohai, always the same problem virtualization.rb doesn't detect the container has a guest.
With native ohai same problem.
On same environment, without docker installed in the host, it works fine.

Ohai Version

From 7.0.4 to latest (maybe before)

Platform Version

Host : Ubuntu 16.04
Lxc container : Ubuntu 14.04

Ohai Output

An LXC guest return :

"virtualization": {
    "systems": {

    }

On an LXC container running on a physical host without docker :

  "virtualization": {
    "system": "lxc",
    "role": "guest"
  },

Content of cgroup inside the ubuntu 14.04 containers :

cat /proc/1/cgroup 
9:cpu,cpuacct:/
8:pids:/
7:devices:/
6:cpuset:/
5:blkio:/
4:net_cls,net_prio:/
3:freezer:/
2:memory:/
1:name=systemd:/
root@crawler01:~# cat /proc/self/cgroup 
9:cpu,cpuacct:/
8:pids:/
7:devices:/
6:cpuset:/
5:blkio:/
4:net_cls,net_prio:/
3:freezer:/
2:memory:/
1:name=systemd:/

The problem seems here :
file virtualization.rb line 180

if File.read("/proc/self/cgroup") =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$}

I'm currently searching a way to find any difference to be able to know if a container is lxc or docker from inside the container.

@huckley
Copy link

huckley commented Aug 25, 2016

cat /proc/1/environ say what?

@goacid
Copy link
Author

goacid commented Aug 25, 2016

container=lxccontainer_ttys=/dev/pts/0 /dev/pts/1 /dev/pts/2 /dev/pts/3

Yes !
Next step : patching the file

@lehn-etracker
Copy link

lehn-etracker commented Aug 25, 2016

See my patch here master...lehn-etracker:lxc-2.0
I will send a pull request after signing Chef CLA!

@goacid
Copy link
Author

goacid commented Aug 25, 2016

Thanks !

@jeunito
Copy link
Contributor

jeunito commented Sep 8, 2017

This was an issue for me too. I have made another PR with tests passing at #1055

@tas50
Copy link
Contributor

tas50 commented Sep 9, 2017

This should be fixed on master now with the updated PR from @jeunito

@tas50 tas50 closed this as completed Sep 9, 2017
@chef chef locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants