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

If it can't connect to lldpd daemon custom fact lldp should not return MalformedDataError #152

Open
kBite opened this issue May 3, 2023 · 1 comment · May be fixed by #153
Open

If it can't connect to lldpd daemon custom fact lldp should not return MalformedDataError #152

kBite opened this issue May 3, 2023 · 1 comment · May be fixed by #153

Comments

@kBite
Copy link
Contributor

kBite commented May 3, 2023

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.x, 8.x
  • Ruby: 2.7.x, 3.2.x
  • Distribution: AlmaLinux 8, AlmaLinux 9
  • Module version: every version since v3.3.0-2-g14a43

How to reproduce ( including debug output)

# facter -p lldp
[2023-05-03 18:29:28.181294 ] WARN Facter - invalid or malformed lldp data: MalformedDataError: no lldp interface data found
# facter --debug -p lldp
...
[2023-05-03 18:27:41.184214 ] DEBUG Facter::FactLoader - Loading external facts
[2023-05-03 18:27:41.185501 ] DEBUG Facter::QueryParser - List of resolvable facts: [#<Facter::SearchedFact:0x00007fc09c46b950 @name="lldp", @fact_class=nil, @user_query="lldp", @type=:custom, @file=nil>]
[2023-05-03 18:27:41.185733 ] DEBUG Facter::Core::Execution::Posix - Executing command: /sbin/lldpctl -f json
[2023-05-03 18:27:41.191637 ] DEBUG lldpctl -f json - Command /sbin/lldpctl -f json completed with the following stderr message: 2023-05-03T18:27:41 [WARN/control] unable to connect to socket /run/lldpd/lldpd.socket: No such fil
e or directory
2023-05-03T18:27:41 [WARN/lldpctl] not able to get the list of interfaces. Unable to connect to lldpd daemon
[2023-05-03 18:27:41.191765 ] WARN Facter - invalid or malformed lldp data: MalformedDataError: no lldp interface data found
[2023-05-03 18:27:41.191822 ] DEBUG Facter - /opt/puppetlabs/puppet/cache/lib/facter/lldp.rb:18:in `block (2 levels) in <top (required)>'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/resolution.rb:196:in `resolve_value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:78:in `block (2 levels) in value'
        /opt/puppetlabs/puppet/lib/ruby/3.2.0/timeout.rb:173:in `timeout'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:77:in `block in value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:102:in `with_timing'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:76:in `value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:211:in `block in find_first_real_value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:209:in `each'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:209:in `find_first_real_value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:131:in `block (2 levels) in value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/benchmarking/timer.rb:18:in `measure'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:130:in `block in value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:177:in `searching'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:127:in `value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:21:in `block in external_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:19:in `each'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:19:in `external_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:7:in `resolve_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact_manager.rb:24:in `resolve_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:530:in `resolve_facts_for_user_query'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:461:in `to_user_output'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli.rb:124:in `query'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli_launcher.rb:23:in `start'
        /opt/puppetlabs/puppet/bin/facter:10:in `<main>'
...

What do you expect?

If I understand https://www.puppet.com/docs/puppet/8/custom_facts.html correctly failing to resolve lldp shouldn't return warning, but nil in case lldpd daemon is not running.

If the fact fails to resolve or is not present, Facter returns nil.

If it should keep returning warning (e.g. for compatibility) it should return (a substring of) lldpctl's actual warnings :

# /sbin/lldpctl -f json
2023-05-03T18:28:31 [WARN/control] unable to connect to socket /run/lldpd/lldpd.socket: No such file or directory
2023-05-03T18:28:31 [WARN/lldpctl] not able to get the list of interfaces. Unable to connect to lldpd daemon
{
  "lldp": {

  }
}
@kBite kBite linked a pull request May 3, 2023 that will close this issue
@kBite
Copy link
Contributor Author

kBite commented May 3, 2023

#153 adds a confine statement effectively returning nil in case lldpd is not running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant