From c609d1c9fec510630dfae427ad059dd08e2a3711 Mon Sep 17 00:00:00 2001 From: Jesse Hathaway Date: Mon, 29 Jul 2024 15:52:26 -0500 Subject: [PATCH] Fix lxc container detection Commit 7bc38ccb58e6abf66d6141a3b2e9f60eb0077d71 removed the regex matching for lxc, /container=lxc/, and instead matched the env var exactly, using the value lxcroot from the rspec test. However, I can find no evidence that lxc ever sets container to anything other than lxc, so change lxcroot to lxc [1][2]. [1]: https://codesearch.debian.net/search?q=container%3Dlxc&literal=1 [2]: https://github.com/search?q=container%3Dlxcroot&type=code Fixes: #2737 --- lib/facter/resolvers/containers.rb | 2 +- spec/facter/resolvers/containers_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/facter/resolvers/containers.rb b/lib/facter/resolvers/containers.rb index 52d3c00f48..3992f48ec4 100644 --- a/lib/facter/resolvers/containers.rb +++ b/lib/facter/resolvers/containers.rb @@ -43,7 +43,7 @@ def read_environ(fact_name) info = {} case container - when 'lxcroot' + when 'lxc' vm = 'lxc' when 'podman' vm = 'podman' diff --git a/spec/facter/resolvers/containers_spec.rb b/spec/facter/resolvers/containers_spec.rb index 1941469e79..120c777d01 100644 --- a/spec/facter/resolvers/containers_spec.rb +++ b/spec/facter/resolvers/containers_spec.rb @@ -66,7 +66,7 @@ context 'when hypervisor is lxc and it is discovered by environ' do let(:cgroup_output) { load_fixture('cgroup_file').read } - let(:environ_output) { ['container=lxcroot'] } + let(:environ_output) { ['container=lxc'] } let(:result) { { lxc: {} } } it 'return lxc for vm' do