Bug #2590

--modulepath ignored

Added by Thomas Bellman almost 4 years ago. Updated about 2 years ago.

Status:InvestigatingStart date:09/03/2009
Priority:HighDue date:
Assignee:Jeff McCune% Done:

100%

Category:-
Target version:-
Affected Puppet version:0.25.4 Branch:
Keywords:

Description

It seems that at least the stand-alone ‘puppet’ executable ignores —modulepath. Given the following minimal manifest set:

    $ pwd
    /config/0.25
    $ find . -type f -print
    ./manifests/site.pp
    ./modules/testmodule/manifests/init.pp

    $ cat manifests/site.pp
    import "testmodule"

    node default
    {
    include moduleclass
    }

    $ cat modules/testmodule/manifests/init.pp
    class moduleclass
    {
    file {
        "/tmp/testfile":
        ensure => file, content => "${puppetversion}\n";
    }
    }

I get the following results:

    # puppet --modulepath=/config/0.25/modules manifests/site.pp
    Could not parse for environment production: No file(s) found for
    import of 'testmodule' at /config/0.25/manifests/site.pp:3

This works as expected in 0.24.8. Bisecting shows that it was introduced with commit d397f8d1d1092067f7ca52449ce9af63f02f44e1 (Fixing #2574 – autoloading finds plugins in modules) on 2009-09-01 01:01:17.

I have only tried the stand-alone puppet program, not the puppetd / puppetmasterd combination.

Adding —debug —trace I get the following traceback:

    /usr/lib/ruby/site_ruby/1.8/puppet/parser/parser_support.rb:172:in `import'
    grammar.ra:639:in `_reduce_156'
    grammar.ra:638:in `each'
    grammar.ra:638:in `_reduce_156'
    /usr/lib/ruby/site_ruby/1.8/facter/util/ip.rb:141:in `_racc_yyparse_c'
    /usr/lib/ruby/site_ruby/1.8/facter/util/ip.rb:141:in `catch'
    /usr/lib/ruby/site_ruby/1.8/facter/util/ip.rb:141:in `_racc_yyparse_c'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/lexer.rb:446:in `scan'
    /usr/lib/ruby/1.8/racc/parser.rb:152:in `_racc_yyparse_c'
    /usr/lib/ruby/1.8/racc/parser.rb:152:in `__send__'
    /usr/lib/ruby/1.8/racc/parser.rb:152:in `yyparse'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/parser_support.rb:430:in `parse'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/interpreter.rb:71:in `create_parser'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/interpreter.rb:54:in `parser'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/interpreter.rb:27:in `compile'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:88:in `compile'
    /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:181:in `benchmark'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:86:in `compile'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:35:in `find'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:198:in `find'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:51:in `find'
    /usr/lib/ruby/site_ruby/1.8/puppet/application/puppet.rb:116:in `main'
    /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/bin/puppet:71
    Could not parse for environment production: No file(s) found for import of 'testmodule' at /config/0.25/manifests/site.pp:3

Related issues

Related to Puppet - Bug #2574: Plugins cannot be loaded directly from modules Closed 08/27/2009
Duplicated by Puppet - Bug #2774: puppetmasterd with Passenger doesn't read puppet.conf cor... Duplicate 11/03/2009
Duplicated by Puppet - Bug #2832: too much caching of the directory in which a module was f... Duplicate 11/18/2009

History

#1 Updated by Markus Roberts almost 4 years ago

  • Status changed from Unreviewed to Accepted

#2 Updated by Luke Kanies almost 4 years ago

  • Status changed from Accepted to Ready For Checkin
  • Assignee set to James Turnbull

Fixed in the tickets/master/2590 branch in my repo.

#3 Updated by Luke Kanies almost 4 years ago

And for the record, the problem was that modulepath was cached at the wrong time.

#4 Updated by James Turnbull almost 4 years ago

  • Status changed from Ready For Checkin to Closed

Pushed in commit:ea5847875b5fd7e2d13470d9e74bb0f671ee4d95 in branch master.

#5 Updated by John Barbuto almost 4 years ago

I’m still seeing this problem with the puppetd/puppetmasterd combination. I have a custom modulepath in puppet.conf, and modules in the non-default path aren’t found by puppetmasterd until 15 seconds after it’s started — the default value of filetimeout. This is especially noticeable with Passenger, due to its on-demand puppetmasterd spawning and shutdown of idle instances. Reverting commit d397f8 fixes it in my setup.

#6 Updated by James Turnbull over 3 years ago

  • Status changed from Closed to Re-opened
  • Target version changed from 0.25.0 to 0.25.2
  • Affected Puppet version changed from 0.25.0 to 0.25.1

#7 Updated by Markus Roberts over 3 years ago

At a guess, it looks like d397f8’s late loading:

     def module_directories
-        Puppet.settings.value(:modulepath, Puppet[:environment]).find_all do |dir|
-            FileTest.directory?(dir)
-        end.collect do |dir|
-            Dir.entries(dir)
+        # We have to require this late in the process because otherwise we might have
+        # load order issues.
+        require 'puppet/node/environment'
+        Puppet::Node::Environment.new.modulepath.collect do |dir|
+            Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| File.join(dir, f) }
         end.flatten.collect { |d| [File.join(d, "plugins"), File.join(d, "lib")] }.flatten.find_all do |d|
             FileTest.directory?(d)
         end

Thwarts ea584787’s modulepath clearing (doesn’t clear it ‘cause it isn’t loaded yet).

@@ -494,7 +494,15 @@ class Puppet::Util::Settings
         @sync.synchronize do # yay, thread-safe
             @values[type][param] = value
             @cache.clear
+
             clearused
+
+            # Clear the list of environments, because they cache, at least, the module path.
+            # We *could* preferentially just clear them if the modulepath is changed,
+            # but we don't really know if, say, the vardir is changed and the modulepath
+            # is defined relative to it. We need the defined? stuff because of loading
+            # order issues.
+            Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
         end

#8 Updated by Markus Roberts over 3 years ago

  • Assignee changed from James Turnbull to Luke Kanies

I’m switching this from James back to Luke because it looks like the assignment to James is just a remnant of the prior checkin.

#9 Updated by Luke Kanies over 3 years ago

I can’t reproduce this, either with puppetd and puppetmasterd, or with the standalone puppet.

What, specifically, are you trying to load? A manifest? Plugin?

I think the problem is unrelated to environments – autoload instances would get expired differently than environments. That is, I think both environments and autoloader instances are caching information, and we’re only clearing the environments.

What about if you apply this patch to your master?

diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index f2c513b..e879cf9 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -511,6 +511,7 @@ class Puppet::Util::Settings
             # is defined relative to it. We need the defined? stuff because of loading
             # order issues.
             Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
+            Puppet::Util::Cacher.expire
         end
 
         return value

Do you still see the problem?

#10 Updated by Markus Roberts over 3 years ago

  • Status changed from Re-opened to Needs More Information
  • Assignee deleted (Luke Kanies)

#11 Updated by Jesse Wolfe over 3 years ago

  • Assignee set to Thomas Bellman
  • Target version changed from 0.25.2 to 0.25.3

#12 Updated by Thomas Bellman over 3 years ago

  • Assignee deleted (Thomas Bellman)

I think it should be assigned to John A. Barbuto, not to me, since it was he who saw the new problem. When I lightly test 0.25.2rc2, modulepath seems to behave as it should in my settings (both stand-alone puppet and puppetd/puppetmasterd).

#13 Updated by Markus Roberts over 3 years ago

  • Assignee set to John Barbuto

John —

Can you reproduce the problem with 0.25.2? If so, please post enough details to allow us to do the same; if not post that so we can close the ticket.

— Markus

#14 Updated by Markus Roberts over 3 years ago

  • Target version changed from 0.25.3 to 0.25.4

#15 Updated by Steve Feehan over 3 years ago

Markus Roberts wrote:

John —

Can you reproduce the problem with 0.25.2? If so, please post enough details to allow us to do the same; if not post that so we can close the ticket.

— Markus

Markus, We’re also experiencing this bug and can reproduce with 0.25.2. The one line patch Luke gave for lib/puppet/util/settings.rb did not make any difference.

This only causes us trouble when run via passenger. Running puppetmasterd with webrick does not exhibit the bug.

Our versions are:

  puppet: 0.25.2
  ruby: 1.8.7
  passenger: 2.2.8
  apache: httpd-2.2.3-22.el5.centos

config.ru file is:

# a config.ru, for use with every rack-compatible webserver.
# SSL needs to be handled outside this, though.

# if puppet is not in your RUBYLIB:
# $:.unshift('/opt/puppet/lib')

$0 = "puppetmasterd"
require 'puppet'

# if you want debugging:
#ARGV << "--debug"

ARGV << "--rack"
require 'puppet/application/puppetmasterd'
# we're usually running inside a Rack::Builder.new {} block,
# therefore we need to call run *here*.
run Puppet::Application[:puppetmasterd].run

[puppetmaster] section of puppet.conf is:

[puppetmasterd]
    autosign = $confdir/autosign.conf
    modulepath = /export/home/puppet/modules
    manifestdir = /export/home/puppet/manifests
    templatedir = /export/home/puppet/templates

One other interesting note: if you turn on —trace in the config.ru, then the problem goes away. Ex:

ARGV << "--trace"

Let me know if there is any additional info I can provide. It should be pretty easy to reproduce if using passenger.

Steve

#16 Updated by James Turnbull over 3 years ago

  • Target version changed from 0.25.4 to 0.25.5

#17 Updated by Steve Feehan over 3 years ago

I tried 0.25.4 today and it still exhibits the same behavior (I saw that it had been pushed to 0.25.5, but figured I’d try anyhow).

One point that I made in my previous post that may have slipped through the cracks, but I think is interesting:

if you enable —trace in the config.ru file, the problem goes away. And I can’t see that any extra trace logging is happening. No noticeable performance hit either.

Again, if there is anything I can do to help a developer reproduce this bug I’ll be happy to help.

Steve

#18 Updated by Alan Barrett over 3 years ago

As of puppet-0.25.4, the reproduction recipe in Bug #2832 (which is marked as a duplicate of this bug) still shows the problem. I use the default web server built in to puppetd, not passenger.

#19 Updated by Aurélien Cedeyn over 3 years ago

Hi, Same problem here with passenger 2.2.5 and puppet 0.25.4. Instead of the —trace option, I use the —ignorecache option in the config.ru as workaround.

Aurélien

#20 Updated by James Turnbull about 3 years ago

  • Target version changed from 0.25.5 to 49

#21 Updated by Anonymous about 3 years ago

  • Status changed from Needs More Information to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:ea5847875b5fd7e2d13470d9e74bb0f671ee4d95.

#22 Updated by Anonymous about 3 years ago

  • Status changed from Closed to Unreviewed
  • Target version changed from 49 to 2.6.0
  • Affected Puppet version changed from 0.25.1 to development

I’m still seeing this problem on latest master also with “puppet main -v —modulepath somepath /path/to/test.pp”, doesn’t work, so I’m reopening on the new version.

I tried adding modulepath to the configuration files and it doesn’t seem that puppet’s CLI is observing those either, though this could be user error on my part, I suspect it is ignoring module path in general and not just the —modulepath.

#23 Updated by James Turnbull about 3 years ago

  • Status changed from Unreviewed to Accepted

#24 Updated by Bjørn Remseth about 3 years ago

I’m also seeing this behavior on puppet 0.24.8 on ubuntu 9.10 (karmic koala). Since I’m a newbie I don’t know what the equivalent of a “config.ru” file is, so I can’t apply the workarounds mentioned above.

Does anyone have a hint on another workaround, or a hint on where I can find config.ru on my system? (“locate” couldn’t find it even after running updatedb, so I’m pretty certain that there are no config.ru files on my system).

#25 Updated by Anonymous about 3 years ago

  • Status changed from Accepted to Closed

Applied in changeset commit:ea5847875b5fd7e2d13470d9e74bb0f671ee4d95.

#26 Updated by James Turnbull about 3 years ago

  • Status changed from Closed to Accepted

#27 Updated by Markus Roberts about 3 years ago

Does anyone know who the “anonymous” user that keeps (incorrectly, so far as I can tell) closing this ticket is?

#28 Updated by James Turnbull about 3 years ago

That’s Redmine. I’m turning the feature off. More trouble than good.

#29 Updated by Luke Kanies about 3 years ago

  • Status changed from Accepted to Needs More Information
  • Assignee changed from John Barbuto to Luke Kanies

Is this actually still a problem? We’re rushing to get a few tickets into rowlf, but I can’t fix this if I can’t reproduce it.

#30 Updated by Jesse Wolfe about 3 years ago

  • Target version changed from 2.6.0 to 52

#31 Updated by Sharif Nassar almost 3 years ago

I was testing upgrading a dev puppetmaster from puppet 0.24.8 to 0.25.4 this weekend, and had the same issues.

debug: Calling fileserver.list
err: /File[/var/puppet/lib]: Failed to generate additional resources during transaction: None of the provided sources existdebug: Calling fileserver.describe
err: /File[/var/puppet/lib]: Failed to retrieve current state of resource: No specified source was found from puppet://pm.sharif.example.com/plugins
[SNIP]
err: Could not retrieve catalog: Could not find class server at /etc/puppet/manifests/nodes.pp:25 on node lenny64.sharif.example.com

Relevant info: Apache + passenger 2.2.5 puppet 0.25.4 from Debian backports (yes this is all very old, but it’s what I had already downloaded when I was playing on the airplane)

I used the boilerplate config.ru in the distribution. I tried the work around of adding ARGV << “—trace” in config.ru and suddenly it all works.

/etc/puppet/puppet.conf on the puppetmaster:

[main]
  factpath = $vardir/lib/facter
  logdir = /var/log/puppet
  pidfile = /var/run/puppet/puppetd.pid
  pluginsync = true
  puppetdlog = $logdir/puppetd.log
  puppetport = 8139
  runinterval = 14400
  splay = true
  server = pm.sharif.example.com
  rundir = /var/run/puppet
  vardir = /var/lib/puppet
  ssldir = /var/lib/puppet/ssl
  verbose = true
  debug = true

[puppetmasterd]
  modulepath = /var/lib/puppet/modules:/etc/puppet/manifests/modules:/etc/puppet/manifests/modules/base:/etc/puppet/manifests/modules/site:/etc/puppet/manifests/modules/deploy
  reports = log
  ssl_client_header = SSL_CLIENT_S_DN
  ssl_client_verify_header = SSL_CLIENT_VERIFY
  templatedir = /var/lib/puppet/templates
  pidfile = /var/run/puppet/puppetmasterd.pid

#32 Updated by James Turnbull almost 3 years ago

  • Assignee changed from Luke Kanies to Markus Roberts
  • Target version changed from 52 to 2.6.0

#33 Updated by Luke Kanies almost 3 years ago

  • Assignee changed from Markus Roberts to Jeff McCune

Jeff is doing some Passenger testing, so we’ll have him test this, also.

#34 Updated by Markus Roberts almost 3 years ago

  • Status changed from Needs More Information to Investigating
  • Target version changed from 2.6.0 to 52
  • Affected Puppet version changed from development to 0.25.4

Reversing yesterday’s target assignment: 1) this exists in 0.25.x, and if we find a fix soon we’ll want it there; 2) we do not have ready fix; 3) there is reason to believe it may be an upstream problem, or linked to one.

#35 Updated by James Turnbull over 2 years ago

  • Target version deleted (52)

#36 Updated by Peter Meier about 2 years ago

fyi:

puppet apply --modulepath=/home/duritong/dev/puppet/modules/public/:/home/duritong/dev/puppet/modules/site/ manifests/site.pp
or
puppet --modulepath=/home/duritong/dev/puppet/modules/public/:/home/duritong/dev/puppet/modules/site/ manifests/site.pp

Works on Debian Puppet 2.6.7, I’m not sure if this is still a bug

Also available in: Atom PDF