-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect hypervisors
and virtual
Facts with Unsupported Container Runtime Warning in Docker
#2781
Comments
Thank you for reporting this @molhamalnasr , we have added this issue to our backlog. |
Migrated issue to FACT-3488 |
@molhamalnasr I can't reproduce this ever working. In particular,
Also it doesn't appear any version of facter correctly detects those facts:
EDIT: The EDIT: Commit 7bc38cc#diff-79c60e634be9bb4ac1da2dd02e3563d596b747d0135748bc1486cbb49f93380fR18 changed the order of reading from the environment vs cgroup. If |
puppetlabs#2781) Previously, the `Containers` resolver would always return a value from `read_environ`, preventing `read_cgroup` from being called. As a result, the `hypervisors` and `virtual` facts were often set incorrectly to `container_other` and displayed a misleading warning. Changes in this commit: - `read_cgroup` now returns early unless Docker or LXC matches are found. - `read_environ` returns `nil` when encountering an unsupported container. - If both methods return `nil`, `vm` defaults to `container_other` with a warning. These updates ensure that Facter correctly detects Docker and properly reports the `virtual` and `hypervisors` facts when running inside a Docker container.
Hi @joshcooper Thanks for checking into this! The difference I’m seeing is due to setting the environment variable Dockerfile for Ubuntu 22.04 (Puppet Agent 7.30.0)FROM ubuntu:22.04
ARG version="7.30.0"
ENV PUPPET_AGENT_VERSION="$version"
ENV PUPPET_SRV_VERSION="2021.7.8"
ENV UBUNTU_CODENAME="jammy"
ENV DONWLOAD_URI="https://pm.puppetlabs.com/puppet-agent/${PUPPET_SRV_VERSION}/${PUPPET_AGENT_VERSION}/repos/deb/${UBUNTU_CODENAME}/puppet7/puppet-agent_${PUPPET_AGENT_VERSION}-1${UBUNTU_CODENAME}_amd64.deb"
ENV PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin
ENV container=docker
RUN apt-get update && \
apt-get -y dist-upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
curl \
systemd \
systemd-cron \
wget \
sudo \
ca-certificates
RUN wget $DONWLOAD_URI && \
dpkg -i puppet-agent_${PUPPET_AGENT_VERSION}-1${UBUNTU_CODENAME}_amd64.deb && \
rm puppet-agent_${PUPPET_AGENT_VERSION}-1${UBUNTU_CODENAME}_amd64.deb
CMD ["/sbin/init", "--log-target=journal"] Dockerfile for Ubuntu 24.04 (Puppet Agent 7.32.1)FROM ubuntu:24.04
ARG version="7.32.1"
ENV PUPPET_AGENT_VERSION="$version"
ENV PUPPET_SRV_VERSION="2021.7.9"
ENV UBUNTU_CODENAME="noble"
ENV DONWLOAD_URI="https://pm.puppetlabs.com/puppet-agent/${PUPPET_SRV_VERSION}/${PUPPET_AGENT_VERSION}/repos/deb/${UBUNTU_CODENAME}/puppet7/puppet-agent_${PUPPET_AGENT_VERSION}-1${UBUNTU_CODENAME}_amd64.deb"
ENV PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin
ENV container=docker
RUN apt-get update && \
apt-get -y dist-upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
curl \
systemd \
systemd-cron \
wget \
sudo \
ca-certificates
RUN wget $DONWLOAD_URI && \
dpkg -i puppet-agent_${PUPPET_AGENT_VERSION}-1${UBUNTU_CODENAME}_amd64.deb && \
rm puppet-agent_${PUPPET_AGENT_VERSION}-1${UBUNTU_CODENAME}_amd64.deb
CMD ["/sbin/init", "--log-target=journal"] Testing Facter 4.8.0 vs. 4.7.0
As you can see, with 4.8.0 it logs a warning and sets I hope this helps clarify the difference. Please let me know if you have any questions or need more details. |
Thanks @molhamalnasr! Could you provide more details about why you're running the agent in docker? And what you meant by
|
Describe the Bug
When running Puppet Facter inside a Docker container, the
hypervisors
andvirtual
facts are incorrectly set. Additionally, a warning is displayed:Warning: Facter: Container runtime, 'docker', is unsupported, setting to, 'container_other'
.Example Output:
Expected Behavior
In previous versions (e.g., Tag 4.7.0), the
hypervisors
andvirtual
facts returned the correct values:Steps to Reproduce
facter -p hypervisors
orfacter -p virtual
.Environment
Additional Context
After debugging the repository, I identified the root cause in the following line within
lib/facter/resolvers/containers.rb
:The call to
read_environ(fact_name)
always returns a value, which preventsread_cgroup(fact_name)
from being executed. This causes the resolver to misidentify the container runtime and set incorrect values for thehypervisors
andvirtual
facts.The text was updated successfully, but these errors were encountered: