Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-1597

"contain" cannot contain a fully qualified class

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 3.4.2
    • Fix Version/s: PUP 3.7.0
    • Component/s: DSL, Server
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Week 2014-4-30 to 2014-5-7, Week 2014-5-7 to 2014-5-14, Week 2014-5-21 to 2014-5-28

      Description

      nested contains don't appeare to work. I'm hitting this issue when trying to contain puppetlabs/mysql::client, but the issue can be reproduced quite simply:

      #
      class mybug::client (
        $package_ensure  = 'present',
        $package_name    = 'mysql',
      ){
        package { 'mybug_client':
          ensure => $mybug::client::package_ensure,
          name   => $mybug::client::package_name,
        }
      }
      

      class profile::mybug {
        contain ::mybug::client
      }
      

      Now, if we call puppet apply --debug -e 'include ::profile::mybug', we get:

      WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.9.1
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
      Warning: Could not retrieve fact fqdn
      Debug: importing '/etc/puppet/modules/profile/manifests/mybug.pp' in environment production
      Debug: Automatically imported profile::mybug from profile/mybug into production
      Debug: importing '/etc/puppet/modules/mybug/manifests/init.pp' in environment production
      Debug: importing '/etc/puppet/modules/mybug/manifests/client.pp' in environment production
      Debug: Automatically imported mybug::client from mybug/client into production
      Debug: hiera(): Hiera YAML backend starting
      Debug: hiera(): Looking up mybug::client::package_ensure in YAML backend
      Debug: hiera(): Looking for data source production
      Debug: hiera(): Cannot find datafile /var/lib/hiera/production.yaml, skipping
      Debug: hiera(): Looking for data source global
      Debug: hiera(): Looking up mybug::client::package_name in YAML backend
      Debug: hiera(): Looking for data source production
      Debug: hiera(): Cannot find datafile /var/lib/hiera/production.yaml, skipping
      Debug: hiera(): Looking for data source global
      Error: undefined method `ref' for nil:NilClass on node levix
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:527:in `block in to_catalog'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:515:in `each'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:515:in `to_catalog'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:402:in `to_resource'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:24:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:116:in `block (2 levels) in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler/none.rb:6:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler.rb:31:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:114:in `block in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:161:in `block in benchmark'
      /usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:160:in `benchmark'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:113:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:46:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/indirection.rb:201:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:204:in `main'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:146:in `run_command'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block (2 levels) in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:470:in `plugin_hook'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:478:in `exit_on_fail'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:137:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:91:in `execute'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/bin/puppet:4:in `<top (required)>'
      /usr/local/bin/puppet:23:in `load'
      /usr/local/bin/puppet:23:in `<main>'
      Error: undefined method `ref' for nil:NilClass on node levix
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:527:in `block in to_catalog'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:515:in `each'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:515:in `to_catalog'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/resource/catalog.rb:402:in `to_resource'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:24:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:116:in `block (2 levels) in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler/none.rb:6:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler.rb:31:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:114:in `block in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:161:in `block in benchmark'
      /usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:160:in `benchmark'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:113:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:46:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/indirection.rb:201:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:204:in `main'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:146:in `run_command'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block (2 levels) in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:470:in `plugin_hook'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:478:in `exit_on_fail'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:137:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:91:in `execute'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/bin/puppet:4:in `<top (required)>'
      /usr/local/bin/puppet:23:in `load'
      /usr/local/bin/puppet:23:in `<main>'
      

      Alternatively, if we call sudo puppet apply --debug -e 'contain ::mybug::client', we get

      WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.9.1
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
      Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
      Warning: Could not retrieve fact fqdn
      Debug: importing '/etc/puppet/modules/mybug/manifests/init.pp' in environment production
      Debug: importing '/etc/puppet/modules/mybug/manifests/client.pp' in environment production
      Debug: Automatically imported mybug::client from mybug/client into production
      Debug: hiera(): Hiera YAML backend starting
      Debug: hiera(): Looking up mybug::client::package_ensure in YAML backend
      Debug: hiera(): Looking for data source production
      Debug: hiera(): Cannot find datafile /var/lib/hiera/production.yaml, skipping
      Debug: hiera(): Looking for data source global
      Debug: hiera(): Looking up mybug::client::package_name in YAML backend
      Debug: hiera(): Looking for data source production
      Debug: hiera(): Cannot find datafile /var/lib/hiera/production.yaml, skipping
      Debug: hiera(): Looking for data source globalError: undefined method `tag' for nil:NilClass on node levix
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:443:in `block in add_resource_metaparams'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/graph/simple_graph.rb:355:in `block in walk'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/graph/simple_graph.rb:354:in `each'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/graph/simple_graph.rb:354:in `walk'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:432:in `add_resource_metaparams'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:419:in `finish'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:119:in `block in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler/none.rb:6:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler.rb:31:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:119:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:24:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:116:in `block (2 levels) in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler/none.rb:6:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler.rb:31:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:114:in `block in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:161:in `block in benchmark'
      /usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:160:in `benchmark'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:113:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:46:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/indirection.rb:201:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:204:in `main'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:146:in `run_command'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block (2 levels) in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:470:in `plugin_hook'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:478:in `exit_on_fail'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:137:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:91:in `execute'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/bin/puppet:4:in `<top (required)>'
      /usr/local/bin/puppet:23:in `load'
      /usr/local/bin/puppet:23:in `<main>'
      Error: undefined method `tag' for nil:NilClass on node levix
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:443:in `block in add_resource_metaparams'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/graph/simple_graph.rb:355:in `block in walk'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/graph/simple_graph.rb:354:in `each'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/graph/simple_graph.rb:354:in `walk'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:432:in `add_resource_metaparams'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:419:in `finish'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:119:in `block in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler/none.rb:6:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler.rb:31:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:119:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/parser/compiler.rb:24:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:116:in `block (2 levels) in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler/none.rb:6:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/profiler.rb:31:in `profile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:114:in `block in compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:161:in `block in benchmark'
      /usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:160:in `benchmark'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:113:in `compile'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/catalog/compiler.rb:46:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/indirector/indirection.rb:201:in `find'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:204:in `main'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application/apply.rb:146:in `run_command'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block (2 levels) in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:470:in `plugin_hook'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `block in run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util.rb:478:in `exit_on_fail'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/application.rb:364:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:137:in `run'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/lib/puppet/util/command_line.rb:91:in `execute'
      /var/lib/gems/1.9.1/gems/puppet-3.4.2/bin/puppet:4:in `<top (required)>'
      /usr/local/bin/puppet:23:in `load'
      /usr/local/bin/puppet:23:in `<main>'
      

        Issue Links

          Activity

          Hide
          igalic Igor Galić added a comment -

          By popular request from IRC, I'm adding this link, https://m.xkcd.com/917/ because the title of this bug is not meta enough.

          Show
          igalic Igor Galić added a comment - By popular request from IRC, I'm adding this link, https://m.xkcd.com/917/ because the title of this bug is not meta enough.
          Hide
          andy Andrew Parker added a comment -

          I tried this out and it looks like there isn't a problem with containing something that is containing something. I can reproduce what appears to be the same problem by simply calling contains with a fully qualified class name:

          class a { }
          contain(::a)
          

          > be puppet apply t.pp
          Error: undefined method `tag' for nil:NilClass on node aparker.corp.puppetlabs.net
          Error: undefined method `tag' for nil:NilClass on node aparker.corp.puppetlabs.net
          

          Show
          andy Andrew Parker added a comment - I tried this out and it looks like there isn't a problem with containing something that is containing something. I can reproduce what appears to be the same problem by simply calling contains with a fully qualified class name: class a { } contain(::a) > be puppet apply t.pp Error: undefined method `tag' for nil:NilClass on node aparker.corp.puppetlabs.net Error: undefined method `tag' for nil:NilClass on node aparker.corp.puppetlabs.net
          Hide
          igalic Igor Galić added a comment -

          Thanks. Renaming this issue

          Show
          igalic Igor Galić added a comment - Thanks. Renaming this issue
          Hide
          henrik.lindberg Henrik Lindberg added a comment -

          The fix was very easy. The contain function did not honour the API. When looking up a resource in the compiler leading '::' must always be dropped. The result was that it formed an edge between nil and the container. This caused breakage later when the recorded edge was evaluated.

          Show
          henrik.lindberg Henrik Lindberg added a comment - The fix was very easy. The contain function did not honour the API. When looking up a resource in the compiler leading '::' must always be dropped. The result was that it formed an edge between nil and the container. This caused breakage later when the recorded edge was evaluated.
          Hide
          andy Andrew Parker added a comment -

          Looking over Henrik's fix for this, I noticed that contain() also doesn't work correctly with relatively named classes (e.g. class foo { contain bar }}} pulling in {{foo::bar rather than ::bar). Fixing that problem also fixes this problem.

          Show
          andy Andrew Parker added a comment - Looking over Henrik's fix for this, I noticed that contain() also doesn't work correctly with relatively named classes (e.g. class foo { contain bar }}} pulling in {{foo::bar rather than ::bar ). Fixing that problem also fixes this problem.
          Hide
          igalic Igor Galić added a comment -

          \o/

          Show
          igalic Igor Galić added a comment - \o/
          Hide
          andy Andrew Parker added a comment -

          I changed include to return the resources that it brought in. I just want to make sure that these don't leak into the manifests since the language cannot handle the resource objects themselves.

          Show
          andy Andrew Parker added a comment - I changed include to return the resources that it brought in. I just want to make sure that these don't leak into the manifests since the language cannot handle the resource objects themselves.
          Hide
          henrik.lindberg Henrik Lindberg added a comment -

          Merged to master fbc9664

          Show
          henrik.lindberg Henrik Lindberg added a comment - Merged to master fbc9664
          Hide
          kurt.wall Kurt Wall added a comment -

          Verified in master at SHA=1401050.

          # x.pp
          class a { 
          	notice ( 'in class a' )
          }
          contain(::a)
           
          # bundle exec puppet apply x.pp
          Notice: Scope(Class[A]): in class a
          Notice: Compiled catalog for ubuntu.localdomain in environment production in 0.01 seconds
          Notice: Finished catalog run in 0.02 seconds
          

          Show
          kurt.wall Kurt Wall added a comment - Verified in master at SHA=1401050. # x.pp class a { notice ( 'in class a' ) } contain(::a)   # bundle exec puppet apply x.pp Notice: Scope(Class[A]): in class a Notice: Compiled catalog for ubuntu.localdomain in environment production in 0.01 seconds Notice: Finished catalog run in 0.02 seconds

            People

            • Assignee:
              Unassigned
              Reporter:
              igalic Igor Galić
              QA Contact:
              Kurt Wall
            • Votes:
              2 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Agile