Bug #2823

fail and unhelpful error message if a remote directory doesn't exist.

Added by Peter Meier about 2 years ago. Updated about 1 year ago.

Status:Rejected Start date:11/16/2009
Priority:Normal Due date:
Assignee:Dan Bode % Done:

0%

Category:file
Target version:0.25.2
Affected Puppet version:0.25.1 Branch:
Keywords:
Votes: 2

Description

Given the following define

define modules_dir (
    $mode = 0644, $owner = root, $group = 0
  )
{
  $dir = "/var/lib/puppet/modules/${name}"
  if defined(File[$dir]) {
    debug("${dir} already defined")
  } else {
    file {
      "/var/lib/puppet/modules/${name}":
        source => [ "puppet://$server/modules/${name}/modules_dir", "puppet://$server//modules/common/empty"],
        checksum => mtime,
        # ignore the placeholder
        ignore => '\.ignore',
        recurse => true, purge => true, force => true,
        mode => $mode, owner => $owner, group => $group;
    }
  }
}

and the following call:

modules_dir { ["munin", "munin/nodes", "munin/plugins" ]: }

As @$modules/munin/files/nodes/modules_dir@ doesn’t exist, it should take the second fallback and more generic one @$modules/common/files/empty@ which exists.

However the resource fails completely with the following 2 rather cryptic error messages:

/usr/lib/ruby/site_ruby/1.8/puppet/type/file.rb:588:in `recurse_remote'
/usr/lib/ruby/site_ruby/1.8/puppet/type/file.rb:587:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/type/file.rb:587:in `recurse_remote'
/usr/lib/ruby/site_ruby/1.8/puppet/type/file.rb:483:in `recurse'
/usr/lib/ruby/site_ruby/1.8/puppet/type/file.rb:385:in `eval_generate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:347:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:347:in `generate_additional_resources'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:191:in `eval_generate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:238:in `eval_children_and_apply_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:205:in `eval_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:294:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:417:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:416:in `thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:293:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:287:in `collect'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:287:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:142:in `apply'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:153:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:177:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:176:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:152:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent/locker.rb:21:in `lock'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/1.8/sync.rb:229:in `synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:130:in `with_client'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:51:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application/puppetd.rb:103:in `onetime'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:226:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:226:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:217:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:306:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:217:in `run'
/usr/sbin/puppetd:159
err: //Modules_dir[virtual]/File[/var/lib/puppet/modules/virtual]: Failed to generate additional resources using 'eval_generate'
: undefined method `relative_path' for nil:NilClass
/usr/lib/ruby/site_ruby/1.8/puppet/parameter.rb:401:in `fail'
/usr/lib/ruby/site_ruby/1.8/puppet/type/file/source.rb:160:in `init_metadata'
/usr/lib/ruby/site_ruby/1.8/puppet/util/cacher.rb:106:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/util/cacher.rb:106:in `cached_value'
/usr/lib/ruby/site_ruby/1.8/puppet/util/cacher.rb:46:in `metadata'
/usr/lib/ruby/site_ruby/1.8/puppet/type/file/source.rb:115:in `copy_source_values'
/usr/lib/ruby/site_ruby/1.8/puppet/type/file.rb:638:in `retrieve'
/usr/lib/ruby/site_ruby/1.8/puppet/type.rb:726:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:60:in `apply'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:249:in `eval_children_and_apply_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:417:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:416:in `thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:248:in `eval_children_and_apply_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:205:in `eval_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:294:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:417:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:416:in `thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:293:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:287:in `collect'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:287:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:142:in `apply'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:153:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:177:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:176:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:152:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent/locker.rb:21:in `lock'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/1.8/sync.rb:229:in `synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:53:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:130:in `with_client'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:51:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application/puppetd.rb:103:in `onetime'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:226:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:226:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:217:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:306:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:217:in `run'
/usr/sbin/puppetd:159
err: //Modules_dir[virtual]/File[/var/lib/puppet/modules/virtual]: Failed to retrieve current state of resource: Could not retrieve information from source(s) puppet:///modules/virtual/modules_dir, puppet:////modules/common/empty at /srv/puppet/development/modules/public/common/manifests/defines/modules_dir.pp:25

a) it shouldn’t fail completely b) the error message isn’t that helpfull (eval_generate on Nil:Class), but this might be not an issue anymore if the failing is fixed.

tested using latest 0.25.x head.


Related issues

related to Puppet - Bug #2757: symlinks bug in File type (undefined method `to_sym' for ... Closed 10/27/2009

History

Updated by James Turnbull about 2 years ago

  • Category set to file
  • Status changed from Unreviewed to Investigating
  • Assignee set to Markus Roberts
  • Target version set to 0.25.2

Updated by Markus Roberts about 2 years ago

Peter —

I’ve got a test branch up at http://github.com/MarkusQ/puppet/tree/ticket/0.25.x/2823

Could you give it a try and see if it resolves the issue?

— Markus

Updated by Markus Roberts about 2 years ago

  • Status changed from Investigating to Needs More Information
  • Assignee changed from Markus Roberts to Peter Meier

Updated by Peter Meier about 2 years ago

Could you give it a try and see if it resolves the issue?

somehow I found for all the problems relating to that bug a workaround. But I can try to reintroduce the problem in my manifests in the next few days.

Updated by Markus Roberts about 2 years ago

  • Status changed from Needs More Information to In Topic Branch Pending Review

Updated by Markus Roberts about 2 years ago

  • Assignee changed from Peter Meier to Dan Bode

Since Peter hasn’t gotten back, could you try it Dan?

Updated by Dan Bode about 2 years ago

This issue was caused by an extra ‘/’ after $server

“puppet://$server//modules/common/empty”

which is confusing puppet, I am not sure what the expected behavior is.

Your patch does not change the error message in this case.

Here is a the simplified code example that I used for recreate.

class test{
  file{'/tmp/testdir':
    source => 'puppet:////dir',
    recurse => true,
  }
}

This same error message also occurs when you try to access a local path with puppet:

test.pp

file{‘/etc/puppet/duder’: recurse => true, # dir does not exist source => [‘/tmp/fakedir1’], }

[root@collector puppet]# puppet test.pp 
dnsdomainname: Unknown host
err: //File[/etc/puppet/duder]: Failed to generate additional resources using 'eval_generate': undefined method `relative_path' for nil:NilClass
err: //File[/etc/puppet/duder]: Failed to retrieve current state of resource: Could not retrieve information from source(s) /tmp/fakedir1 at /etc/puppet/test.pp:4

Updated by Markus Roberts about 2 years ago

  • Status changed from In Topic Branch Pending Review to Rejected

Good catch. I’d assumed that was just a typo on my part, fixed it in my test case and went on to address a much less plausible mechanism.

Updated by Markus Roberts about 2 years ago

I’ve moved the proposed fix for this onto the code-smell track, since it ought to be fixed in any case.

Updated by Peter Meier about 2 years ago

Markus Roberts wrote:

I’ve moved the proposed fix for this onto the code-smell track, since it ought to be fixed in any case.

hmm yeah, I also removed this typo, maybe this was the actual workaround which helped :/

anyway I didn’t come backup as I got hit by an other problem while testing your patch: #2967

Updated by Steven Seed about 1 year ago

I’d like to see this get fixed. I’m seeing this error when specifying multiple sources for a file resource. This is still happening on 0.25.5. In my case, I’m including a set of search paths in the source, some of which may not exist on certain platforms:

# copy all in-house scripts and binaries locally (including dist specific)
file {"/usr/local/bin":
            source => [ 
                    "puppet:///modules/basebuild/usr/local/bin",
                    "puppet:///modules/basebuild/usr/local/bin.$dist",
            ],
            sourceselect => all,
            recurse => true,
}

Also available in: Atom PDF