Skip to content

Conversation

@alexjfisher
Copy link
Member

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.

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.
@alexjfisher alexjfisher merged commit 611c841 into voxpupuli:master Feb 18, 2025
5 checks passed
@alexjfisher alexjfisher deleted the fix_redefined_entity branch February 18, 2025 19:34
@alexjfisher alexjfisher added the bug Something isn't working label Feb 18, 2025
def remove_resource(scope, resource, soft_fail = nil)
catalog_resource = scope.catalog.resource(resource.type_name, resource.title)
type = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, resource.type_name)
catalog_resource = scope.compiler.findresource(type, resource.title)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants