puppetlabs / facter

Collect and display system facts
https://puppet.com/open-source/#osp
Apache License 2.0
620 stars 497 forks source link

Commit 7bc38ccb has broken libvirt-lxc containers detection #2759

Open turchanov opened 1 month ago

turchanov commented 1 month ago

Commit 7bc38ccb that solves FACT-3202 has broken libvirt-lxc containers detection

Warning: Facter: Container runtime, 'lxc-libvirt', is unsupported, setting to 'container_other'

Before the commit facter code in read_cgroup matched "lxc" on a prefix match, that is any container runtime that was named with prefix "lxc" would have satisfied the test, and an environment string "container=lxc-libvirt" will be detected as a container runtime

https://github.com/puppetlabs/facter/blame/05e4387c8de085a44ff5cfbe02081703dbbf5d60/lib/facter/resolvers/containers.rb#L27

          lxc_from_environ = /container=lxc/ =~ output_environ
joshcooper commented 1 month ago

Thanks @turchanov @lollipopman and I were discussing whether it should be a prefix or exact match in https://github.com/puppetlabs/facter/pull/2741#issue-2436362643 And it sounds like prefix match is preferred. Can you describe steps to reproduce like I did in https://github.com/puppetlabs/facter/pull/2741#issuecomment-2261133368

lollipopman commented 3 weeks ago

I think adding another case statement would be best, as it is technically another type of container, this is how systemd does it:

        [VIRTUALIZATION_SYSTEMD_NSPAWN]  = "systemd-nspawn",
        [VIRTUALIZATION_LXC_LIBVIRT]     = "lxc-libvirt",
        [VIRTUALIZATION_LXC]             = "lxc",
        [VIRTUALIZATION_OPENVZ]          = "openvz",
        [VIRTUALIZATION_DOCKER]          = "docker",
        [VIRTUALIZATION_PODMAN]          = "podman",
        [VIRTUALIZATION_RKT]             = "rkt",
        [VIRTUALIZATION_WSL]             = "wsl",
        [VIRTUALIZATION_PROOT]           = "proot",
        [VIRTUALIZATION_POUCH]           = "pouch",
        [VIRTUALIZATION_CONTAINER_OTHER] = "container-other",

https://github.com/systemd/systemd/blob/49fd31df58a707e7d748581a6986164132460cf2/src/basic/virt.c#L568-L578

turchanov commented 3 weeks ago

Sorry for delay, I am struggling to provide steps to reproduce the bug... (We have a custom procedure to setup lxc containers in libvirt, and I am still looking for the solution)

github-actions[bot] commented 3 weeks ago

Migrated issue to FACT-3484