Skip to content

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

@kBite

Description

@kBite

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": {

  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions