Hi all,

With Puppet 8 coming, I'd like to map out what's required to disable legacy 
facts by default.

First some context, legacy facts are flat key=value pairs and originally 
that's how Facter reported facts. In Facter 3.5 
<https://github.com/puppetlabs/docs-archive/blob/main/puppet/3.5/release_notes.markdown#structured-facts-early-version>,
 
we added support for structured data (hash/array). For compatibility 
reasons, we've been reporting both legacy and structured facts, e.g. 
"osfamily"="Debian" and {"os" => { "family" => "Debian" }}. This way 
manifests that reference legacy facts continue to compile.

So why do we care about disabling legacy facts?

   1. Facter automatically creates multiple legacy facts for each block 
   device, network interface or processor.
   2. Puppetserver adds each top-level variable (including legacy facts) to 
   the scope object used to render ERB templates. This can have a significant 
   impact on compiler performance (PUP-9577 
   <https://tickets.puppetlabs.com/browse/PUP-9577>)
   3. Legacy facts duplicate information in structured facts and we're 
   sending it to puppetserver & puppetdb.

It's possible to block all legacy facts in facter.conf:

facts : {
  blocklist : [ "legacy" ],
}

However, this breaks Puppet, because its builtin providers rely on legacy 
facts, for example, the init provider 
<https://github.com/puppetlabs/puppet/blob/eb498be4bf7b4dbb326dbd479d01101f0b226abb/lib/puppet/provider/service/init.rb#L24-L25>
 relies 
on the legacy "operatingsystem" fact and will fail if the legacy fact is 
missing (PUP-10853 <https://tickets.puppetlabs.com/browse/PUP-10853>)

$ puppet apply -e 'notify { "foo": }'
Error: Could not autoload puppet/provider/service/init: undefined method 
`downcase' for nil:NilClass

The alternative is to define a new fact group and add specific legacy facts 
to it, for example to block processors and network interfaces. 

facts : {
    blocklist : [ "my-legacy-facts" ],
}
fact-groups : {
    my-legacy-facts : [ 
"^(ipaddress6?|mtu|netmask6?|network6?|scope6?)(_.*)?" ]
}

However, Facter 4 slows down as the size of the block list grows (FACT-3161 
<https://tickets.puppetlabs.com/browse/FACT-3161>, FACT-3080 
<https://tickets.puppetlabs.com/browse/FACT-3080>).

For Puppet 7.x, I'd like to:

   1. Add a configuration setting "include_legacy_facts" so Puppet can 
   opt-into not sending legacy facts to puppetserver (PUP-11662 
   <https://tickets.puppetlabs.com/browse/PUP-11662>) In a default agent 
   configuration, this results in 25% less fact data. This is safe so long as 
   legacy facts are not used during compilation (manifests, hiera 
   configuration & data sources). There's already a legacy_facts 
   <https://github.com/mmckinst/puppet-lint-legacy_facts-check> puppet-lint 
   plugin to help users migrate.
   2. Provider confining/suitability won't be affected because 
   "Facter.value(<legacy>)" will still resolve legacy facts on the agent.
   3. Fix the block list slowness

For Puppet 8.0, I'd like to:

   1. Change the default value of "include_legacy_facts" to false (PUP-11430 
   <https://tickets.puppetlabs.com/browse/PUP-11430>)
   2. Change Puppet's builtin type/providers to only reference structured 
   facts (PUP-8543 <https://tickets.puppetlabs.com/browse/PUP-8543>). I 
   think this is only safe to do in Puppet 8, because of the way modules use 
   rspec-puppet & rspec-puppet-facts to stub provider suitability.

Josh

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/a7a9d832-9909-42fc-b5d3-0567a81c8041n%40googlegroups.com.

Reply via email to