Skip to content

Commit af7efd7

Browse files
committed
fix: add oci as supported container runtime
The oci-systemd-hook sets container=oci for PID 1 when running systemd inside OCI containers. This value was not recognized by the container resolver, causing a warning and falling back to container_other. Add oci to the list of known container runtimes to resolve the warning and report the correct virtual fact. Discovered during e2e tests in openvox-operator.
1 parent 38e0a6e commit af7efd7

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

lib/facter/resolvers/linux/containers.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def read_environ(fact_name)
5252
vm = 'podman'
5353
when 'crio'
5454
vm = 'crio'
55+
when 'oci'
56+
vm = 'oci'
5557
when 'zone'
5658
return nil
5759
when 'systemd-nspawn'

spec/facter/resolvers/linux/containers_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@
9292
end
9393
end
9494

95+
context 'when hypervisor is oci and it is discovered by environ' do
96+
let(:cgroup_output) { load_fixture('cgroup_file').read }
97+
let(:environ_output) { ['container=oci'] }
98+
let(:result) { { oci: {} } }
99+
100+
it 'return oci for vm' do
101+
expect(containers_resolver.resolve(:vm)).to eq('oci')
102+
end
103+
104+
it 'return oci info for hypervisor' do
105+
expect(containers_resolver.resolve(:hypervisor)).to eq(result)
106+
end
107+
end
108+
95109
context 'when hypervisor is illumos' do
96110
let(:cgroup_output) { nil }
97111
let(:environ_output) { ['container=zone'] }

0 commit comments

Comments
 (0)