Jira (FACT-2950) Root of structured core facts cannot be overriden by a custom fact

12 views
Skip to first unread message

Bogdan Irimie (Jira)

unread,
Mar 1, 2021, 2:29:01 AM3/1/21
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
 
Facter / Bug FACT-2950
Root of structured core facts cannot be overriden by a custom fact
Change By: Bogdan Irimie
Summary: Structured Root of structured core facts cannot be overriden by a custom fact
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Gheorghe Popescu (Jira)

unread,
Mar 1, 2021, 2:52:03 AM3/1/21
to puppe...@googlegroups.com
Gheorghe Popescu commented on Bug FACT-2950
 
Re: Root of structured core facts cannot be overriden by a custom fact

This issue is affecting modules unit tests that are running with a Puppet 7 that contains the following change(https://github.com/puppetlabs/puppet/commit/c8cea4478f0810d8f20cbc2148b7ad37029a7e57). An example can be seen on puppetlabs-puppet_agent module: https://github.com/puppetlabs/puppetlabs-puppet_agent/runs/2001456000?check_suite_focus=true

This happens because rspec-puppet uses facterdb data to create custom facts in order to stub core system facts. For the `os` fact, it uses the following data:

stubbing os with: {"architecture"=>"x64", "family"=>"windows", "hardware"=>"x86_64", "name"=>"windows", "release"=>{"full"=>"2016", "major"=>"2016"}, "windows"=>{"edition_id"=>"ServerStandard", "installation_type"=>"Server", "product_name"=>"Windows Server 2016 Standard", "release_id"=>"1607", "system32"=>"C:\\Windows\\system32"}}

This will overwrite only the top `os` fact. If any child fact, like `os.name` is called, that fact will be retrieved from system, resulting in unexpected tests behaviour.

Bogdan Irimie (Jira)

unread,
Mar 1, 2021, 3:15:01 AM3/1/21
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Facter represents structured facts as a list of path paths e.g.
{code}os => {
  architecture => "x86_64",
  family => "Darwin",
  ...
  release => {
    full => "20.3.0",
    major => "20",
    minor => "3"
  }
}
{code}
will be represented as
{code}os.architecture
os.family
os.release.full
os.release.major
os.release.minor
{code}
"os" is never represented as a fact name.

When we create a custom fact "os", we don't override the list of facts, we just create a new fact
and add it to that list
{code}os
os.architecture
os.family
os.release.full
os.release.major
os.release.minor
{code}

Mihai Buzgau (Jira)

unread,
Mar 2, 2021, 7:28:56 PM3/2/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 3, 2021, 4:39:02 AM3/3/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Mar 3, 2021, 7:11:01 AM3/3/21
to puppe...@googlegroups.com

Dorin Pleava (Jira)

unread,
Mar 8, 2021, 8:28:02 AM3/8/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Mar 9, 2021, 4:49:02 PM3/9/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Mar 10, 2021, 2:49:03 AM3/10/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Mar 10, 2021, 2:51:03 AM3/10/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Release Notes Summary: Because the top-level fact does not exist, the root of structured core facts could not be overridden by a custom fact. This PR updates the QueryParser logic to return the root fact, if that present in the loaded facts list, thus allowing completely redefinition of core facts.

Gheorghe Popescu (Jira)

unread,
Mar 10, 2021, 2:52:02 AM3/10/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Release Notes Summary: Because the top-level fact does not exist, the root of structured core facts could not be overridden by a custom fact. This PR change updates the QueryParser logic to return the root fact, if that present in the loaded facts list, thus allowing completely redefinition of core facts.

Claire Cadman (Jira)

unread,
Mar 10, 2021, 10:53:30 AM3/10/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages