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

Types that ruby require other types can cause failure

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Do
    • PUP 4.5.0
    • None
    • None
    • Puppet Developer Experience
    • Forge - To Accept

    Description

      Background

      I first saw this issue reported in https://github.com/crayfishx/puppet-firewalld/issues/93 - some resource types need to be able to talk to providers of other resources, such a firewalld_direct_purge in this module. This requires making sure that the type is loaded when this code runs, historically I've always seen this done something like....

      require File.join(File.dirname(__FILE__),'other_type')
      

      With the new resource types system, this seems to break, but only under some circumstances. When the resource type requiring the other type is evaluated first in the manifest, there is never a problem, but when the required resource type is evaluated before the one that requires it, it causes Puppet to throw an error such as:

      Error: Could not autoload puppet/type/test_two: Attempt to redefine entity 'http://puppet.com/2016.1/runtime/type/test_one'. Originally set at file:/etc/puppetlabs/code/environments/production/modules/testmodule/lib/puppet/type/test_one.rb?line=1.
      

      Simulating

      This was a bit complex to try and write up in a ticket, so I've created a tiny test module on github that isolates this problem, details in the README....

      Please see:

      https://github.com/crayfishx/testmodule_demo_code

      If I drop the require statements then the code passes, but that opens up the possibility that the required type has not been loaded when I need to access it's provider, and raises issues for puppet apply....etc so I'm not sure how to solve this

      Attachments

        Activity

          People

            Unassigned Unassigned
            crayfishx Craig Dunn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support