Skip to content

Commit 8aebee8

Browse files
committed
Fix remove_resource Attempt to redefine entity
The previous implementation used to find the resource in the catalog was causing the following style of error on the Puppetserver. ``` Server Error: Evaluation Error: Error while evaluating a Function Call, Could not autoload puppet/type/file_line: Attempt to redefine entity 'http://puppet.com/2016.1/runtime/type/file_line' ``` This only occurred the first time trying to compile the catalog. Subsequent runs against the same puppetserver would work fine. I don't fully understand what was causing the type to be reloaded, and this was only an issue if `generate types` had been used to create the `.resource_types/*.pp` metadata file for the type. Presumably puppet is upset when it tries to load the ruby definition of a type after it's already loaded the pcore version?? In this commit, we switch to the same mechanism used by the `defined` function.
1 parent 4224ae4 commit 8aebee8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/puppet/functions/extlib/remove_resource.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def remove_resources(scope, resources, soft_fail = nil)
4040
end
4141

4242
def remove_resource(scope, resource, soft_fail = nil)
43-
catalog_resource = scope.catalog.resource(resource.type_name, resource.title)
43+
type = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, resource.type_name)
44+
catalog_resource = scope.compiler.findresource(type, resource.title)
4445

4546
if catalog_resource
4647
# To remove the resource, we reverse the actions from compiler.add_resource

0 commit comments

Comments
 (0)