Skip to content

Incorrect hypervisors and virtual Facts with Unsupported Container Runtime Warning in Docker #2781

@molhamalnasr

Description

@molhamalnasr

Describe the Bug

When running Puppet Facter inside a Docker container, the hypervisors and virtual facts are incorrectly set. Additionally, a warning is displayed:
Warning: Facter: Container runtime, 'docker', is unsupported, setting to, 'container_other'.

Example Output:

# facter -p hypervisors
[2024-11-27 13:49:35.972235 ] WARN Facter::Resolvers::Containers - Container runtime, 'docker', is unsupported, setting to, 'container_other'

# facter -p virtual
[2024-11-27 13:49:42.488042 ] WARN Facter::Resolvers::Containers - Container runtime, 'docker', is unsupported, setting to, 'container_other'
container_other

Expected Behavior

In previous versions (e.g., Tag 4.7.0), the hypervisors and virtual facts returned the correct values:

# facter -p hypervisors
{
  docker => {
    id => "<STRING_ID>"
  }
}

# facter -p virtual
docker

Steps to Reproduce

  1. Run Puppet Agent/Facter inside a Docker container.
  2. Execute the command facter -p hypervisors or facter -p virtual.

Environment

  • Version: Puppet Agent 7.32.1
  • Platform: Ubuntu 24.04
  • Facter Version: 4.8.0

Additional Context

After debugging the repository, I identified the root cause in the following line within lib/facter/resolvers/containers.rb:

read_environ(fact_name) || read_cgroup(fact_name)

The call to read_environ(fact_name) always returns a value, which prevents read_cgroup(fact_name) from being executed. This causes the resolver to misidentify the container runtime and set incorrect values for the hypervisors and virtual facts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriagedJira issue has been created for this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions