Skip to content

Commit

Permalink
Linux containers are containers
Browse files Browse the repository at this point in the history
Both Docker and LXC. Also, if we have a virtual_subtype then we're
virtual of *some* kind. Maybe we can't be specific, but we really
shouldn't be saying that we're *physical*
  • Loading branch information
waynew committed Apr 24, 2019
1 parent 6dcb93f commit cf64c4c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,11 +944,13 @@ def _virtual(osdata):
with salt.utils.files.fopen('/proc/1/cgroup', 'r') as fhr:
fhr_contents = fhr.read()
if ':/lxc/' in fhr_contents:
grains['virtual'] = 'container'
grains['virtual_subtype'] = 'LXC'
else:
if any(x in fhr_contents
for x in (':/system.slice/docker', ':/docker/',
':/docker-ce/')):
grains['virtual'] = 'container'
grains['virtual_subtype'] = 'Docker'
except IOError:
pass
Expand Down Expand Up @@ -1051,6 +1053,11 @@ def _virtual(osdata):
if os.path.isfile('/var/run/xenconsoled.pid'):
grains['virtual_subtype'] = 'Xen Dom0'

# If we have a virtual_subtype, we're virtual, but maybe we couldn't
# figure out what specific virtual type we were?
if grains['virtual_subtype'] and grains['virtual'] == 'physical':
grains['virtual'] = 'virtual'

for command in failed_commands:
log.info(
"Although '%s' was found in path, the current user "
Expand Down

0 comments on commit cf64c4c

Please sign in to comment.