Skip to content

Commit

Permalink
Fix lxc container detection
Browse files Browse the repository at this point in the history
Commit 7bc38cc 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
  • Loading branch information
lollipopman committed Jul 29, 2024
1 parent 465c119 commit c609d1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/facter/resolvers/containers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def read_environ(fact_name)

info = {}
case container
when 'lxcroot'
when 'lxc'
vm = 'lxc'
when 'podman'
vm = 'podman'
Expand Down
2 changes: 1 addition & 1 deletion spec/facter/resolvers/containers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c609d1c

Please sign in to comment.