Skip to content
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

(FACT-2799) Fix fact loading for nested fact calls #2108

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

BogdanIrimie
Copy link
Contributor

Problem:

Custom fact i18ndemo_fact was not executed on ubuntu 16.04.

Solution

The fallowing flow happened:
Puppet -> Facter (-> FactLoader -> custom fact(that called puppet again)) -> Puppet -> Facter -> (-> FactLoader -> cached custom facts (this is the reason why it was not an infinit loop))

Because Facter was called from within another Facter run, @external_facts object was replaced and the concat was done on an object thaw was discarded.

With the fix

Ubuntu 16.04

root@gowned-decking:/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter# facter os
{
  architecture => "amd64",
  distro => {
    codename => "xenial",
    description => "Ubuntu 16.04.5 LTS",
    id => "Ubuntu",
    release => {
      full => "16.04",
      major => "16.04"
    }
  },
  family => "Debian",
  hardware => "x86_64",
  name => "Ubuntu",
  release => {
    full => "16.04",
    major => "16.04"
  },
  selinux => {
    enabled => false
  }
}
root@gowned-decking:/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter# rm -rf /opt/puppetlabs/puppet/cache/lib/facter/
root@gowned-decking:/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter]/ensure: created
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/facter_dot_d.rb]/ensure: defined content as '{sha256}8a17c7f9b470dbaaff51e7a4f2103c4e5c4d92667c4b7396cd55d76ebcedab1b'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/i18ndemo_fact.rb]/ensure: defined content as '{sha256}970d26ac91fd7b801062e0c17dcbf6b4ef46be2dd1d4e18adcc1ba0912158006'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/package_provider.rb]/ensure: defined content as '{sha256}4f396a5e0b1016e4ceeb7e9273423171d5a51e083e489c9f8477de88f2c254b6'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/pe_version.rb]/ensure: defined content as '{sha256}9d3a1b46fd1e2d2b604a68994d4b8197b9ca1d8344fe5fa2c2797d8de5742f6f'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/puppet_settings.rb]/ensure: defined content as '{sha256}727f7e6d154cbb5773cea227f6a17019b0a3a73624bbfaa6590ed1de8314ae7b'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/root_home.rb]/ensure: defined content as '{sha256}e857cd21ee4fe14739c8e0f330de645f1f54c41229d608731d4af29a55b8d532'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/service_provider.rb]/ensure: defined content as '{sha256}1beaee8dd3c87c9d887184b9e69c3053762f2261a6ebceaa75f682dab54ba823'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/util]/ensure: created
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/util/puppet_settings.rb]/ensure: defined content as '{sha256}af86574985faba7b25893444917da5197f00bbb39182f7a56123cca6ee71e0f4'
Info: Retrieving locales
Info: Loading facts
Error: Facter: Error while resolving custom fact fact='i18ndemo_fact', resolution='<anonymous>': i18ndemo_fact: this is a raise from a custom fact from eputnam-i18ndemo
Info: Caching catalog for gowned-decking.delivery.puppetlabs.net
Info: Applying configuration version '1601280423'
Notice: Applied catalog in 0.01 seconds

Ubuntu 20.04

root@gowned-boundary:/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter# facter os
{
  architecture => "amd64",
  distro => {
    codename => "focal",
    description => "Ubuntu 20.04 LTS",
    id => "Ubuntu",
    release => {
      full => "20.04",
      major => "20.04"
    }
  },
  family => "Debian",
  hardware => "x86_64",
  name => "Ubuntu",
  release => {
    full => "20.04",
    major => "20.04"
  },
  selinux => {
    enabled => false
  }
}
root@gowned-boundary:/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter# rm -rf /opt/puppetlabs/puppet/cache/lib/facter/
root@gowned-boundary:/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter]/ensure: created
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/facter_dot_d.rb]/ensure: defined content as '{sha256}8a17c7f9b470dbaaff51e7a4f2103c4e5c4d92667c4b7396cd55d76ebcedab1b'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/i18ndemo_fact.rb]/ensure: defined content as '{sha256}970d26ac91fd7b801062e0c17dcbf6b4ef46be2dd1d4e18adcc1ba0912158006'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/package_provider.rb]/ensure: defined content as '{sha256}4f396a5e0b1016e4ceeb7e9273423171d5a51e083e489c9f8477de88f2c254b6'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/pe_version.rb]/ensure: defined content as '{sha256}9d3a1b46fd1e2d2b604a68994d4b8197b9ca1d8344fe5fa2c2797d8de5742f6f'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/puppet_settings.rb]/ensure: defined content as '{sha256}727f7e6d154cbb5773cea227f6a17019b0a3a73624bbfaa6590ed1de8314ae7b'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/root_home.rb]/ensure: defined content as '{sha256}e857cd21ee4fe14739c8e0f330de645f1f54c41229d608731d4af29a55b8d532'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/service_provider.rb]/ensure: defined content as '{sha256}1beaee8dd3c87c9d887184b9e69c3053762f2261a6ebceaa75f682dab54ba823'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/util]/ensure: created
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/util/puppet_settings.rb]/ensure: defined content as '{sha256}af86574985faba7b25893444917da5197f00bbb39182f7a56123cca6ee71e0f4'
Info: Retrieving locales
Info: Loading facts
Error: Facter: Error while resolving custom fact fact='i18ndemo_fact', resolution='<anonymous>': i18ndemo_fact: this is a raise from a custom fact from eputnam-i18ndemo
Info: Caching catalog for gowned-boundary.delivery.puppetlabs.net
Info: Applying configuration version '1601280481'
Notice: Applied catalog in 0.01 seconds

…es. This is needed because the objects change and if we use concat, we would end up concatenating to an object that is discarded.
@BogdanIrimie BogdanIrimie added the bug Something isn't working label Sep 28, 2020
@BogdanIrimie
Copy link
Contributor Author

Jenkins please test this on all

@puppetcla
Copy link

CLA signed by all contributors.

@Filipovici-Andrei Filipovici-Andrei changed the title (FACT-2799) Fix fact loading fort nested fact calls (FACT-2799) Fix fact loading for nested fact calls Sep 28, 2020
@BogdanIrimie
Copy link
Contributor Author

Jenkins please test this on all

@BogdanIrimie BogdanIrimie marked this pull request as ready for review September 29, 2020 08:21
@BogdanIrimie BogdanIrimie requested review from a team September 29, 2020 08:21
@BogdanIrimie BogdanIrimie merged commit 0ab4b39 into puppetlabs:main Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants