Skip to content

Agent raises undefined method 'name' for nil when catalog retrieval fails (regression from #568) #662

Description

@miharp

Versions: openvox-agent 9.0.0-rc1 (Ruby 4.0.6) on CentOS Stream 9 and Ubuntu 24.04; openvox-server 9.0.0-rc1. By inspection the code is present since 9.0.0-beta2. Not reproducible on 8.28.1 (same host, see below).

Steps to reproduce

Any run where the catalog cannot be retrieved and no cached catalog is used, for example:

puppet agent -t --noop --server nosuch.invalid --http_connect_timeout 5s

Actual

Error: Could not retrieve catalog from remote server: No more routes to puppet
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Error: Failed to apply catalog: undefined method 'name' for nil
Error: Could not send report: No more routes to report

Expected

The run stops after Could not retrieve catalog; skipping run, as 8.x does. Same command on 8.28.1 (downgraded on the same EL9 host):

Error: Could not retrieve catalog from remote server: No more routes to puppet
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Error: Could not send report: No more routes to report

Cause

lib/puppet/configurer.rb, prepare_and_retrieve_catalog, since #568 ("Validate that the catalog is compiled for this node"):

      catalog = retrieve_catalog(facts, query_options)
      Puppet.err _("Could not retrieve catalog; skipping run") unless catalog
    end

    if catalog.name != node_name
      Puppet.err _("Catalog name '#{catalog.name}' does not match this node's certname '#{node_name}'")
    end

catalog is nil on failure, so catalog.name raises NoMethodError; run_internal rescues it and logs it as "Failed to apply catalog: ...". Guarding the check (if catalog && catalog.name != node_name, or returning early when catalog is nil) restores the previous behaviour.

Impact

A misleading error on every server outage, and the deliberate skip-run path is replaced by the exception path, which changes what log scrapers and the run report see.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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