Jira (PUP-8260) Using eval_generate with a compound name_vars without a name appears to not work

2 views
Skip to first unread message

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 1:29:03 AM12/18/17
to puppe...@googlegroups.com
Glenn Sarti created an issue
 
Puppet / Bug PUP-8260
Using eval_generate with a compound name_vars without a name appears to not work
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2017/12/17 10:28 PM
Environment:

Windows 10
Puppet Gem 5.3.3
Registry Module PR - https://github.com/puppetlabs/puppetlabs-registry/pull/142

Priority: Normal Normal
Reporter: Glenn Sarti

I have a custom type called registry_key with an eval_generate method which can purge values. The resource types created by eval_generate are registry_value which is now a type with compound namevars. When creating an instance of the type, it is required to pass a title compound namevar types appear to need something simple as a resource key.

This is fine and all works ok.... however in a proper puppet run the generated resources do not appear in the catalog correctly.

I've tracked it down to:
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/transaction/additional_resource_generator.rb#L66

 made = Hash[generated.map(&:name).zip(generated)]

It appears that this code takes each resources :name method and does "something" with it. The issue becomes that the compound namevar types return `nil` for it's name which then screws up the catalog.

After digging into the Puppet::Type type I found a commit (https://github.com/puppetlabs/puppet/commit/607d7c6afec7ab73203382676cc98b6d52898e1d) from Luke back in 2006 which was converting the Puppet::Type name method into title. It appears that additional_resource_generator.rb was never updated to reflect this.

Also there are quotes in the code from that commit

+    # For now, leave the 'name' method functioning like it used to.  Once 'title'
+    # works everywhere, I'll switch it.

Currently:
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type.rb#L2535-L2543

Would it be safe to switch it now after 12 years?

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 1:30:02 AM12/18/17
to puppe...@googlegroups.com
Glenn Sarti commented on Bug PUP-8260
 
Re: Using eval_generate with a compound name_vars without a name appears to not work

I'll spend some time trying to create a repro case for this

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 1:31:02 AM12/18/17
to puppe...@googlegroups.com
Glenn Sarti updated an issue
 
Change By: Glenn Sarti
Team: Platform Core Windows
Sprint: Windows Kanban

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 1:31:03 AM12/18/17
to puppe...@googlegroups.com

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 4:01:03 AM12/18/17
to puppe...@googlegroups.com

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 4:02:02 AM12/18/17
to puppe...@googlegroups.com
Glenn Sarti commented on Bug PUP-8260
 
Re: Using eval_generate with a compound name_vars without a name appears to not work

I've created a minimal repro module

Source - https://github.com/glennsarti/PUP8260-repro PUP8260-repro-master.zip

There are three tests cases, and in each case:

  • A single "parent" resource exists which will purge any unmanaged children
  • Two "child" resources exist (called `managed1` and `managed2`) which will autorequire the "parent"
  • There will appear to be four children that exist for the parent (called `managed1`, `managed2`, `unmanaged1`, and `unmanaged2`) thus it should try to purge the unmanaged entries (called `unmanaged1` and `unmanaged2`)
  • The providers for both the "child" and "parent" are just stubs which write to STDOUT for its various actions e.g. Create, Destroy and Flush

See the README for more information - https://github.com/glennsarti/PUP8260-repro/blob/master/README.md

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 4:03:02 AM12/18/17
to puppe...@googlegroups.com

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 4:03:03 AM12/18/17
to puppe...@googlegroups.com

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 4:03:03 AM12/18/17
to puppe...@googlegroups.com

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 4:05:03 AM12/18/17
to puppe...@googlegroups.com

Glenn Sarti (JIRA)

unread,
Dec 18, 2017, 4:08:03 AM12/18/17
to puppe...@googlegroups.com
Glenn Sarti updated an issue
I have a custom type called registry_key with an eval_generate method which can purge values.  The resource types created by eval_generate are {{registry_value}} which is now a type with compound namevars.  When creating an instance of the type, it is required to pass a title  (  compound namevar types appear to need _something_ simple as a resource key . )

This is fine and all works ok.... however in a proper puppet run the generated resources do not appear in the catalog correctly.

I've tracked it down to:
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/transaction/additional_resource_generator.rb#L66

{code}

 made = Hash[generated.map(&:name).zip(generated)]
{code}


It appears that this code takes each resources :name method and does "something" with it.  The issue becomes that the compound namevar types return `nil` for it's name which then screws up the catalog.

After digging into the Puppet::Type type I found a commit (https://github.com/puppetlabs/puppet/commit/607d7c6afec7ab73203382676cc98b6d52898e1d) from Luke back in 2006 which was converting the Puppet::Type name method into title.  It appears that additional_resource_generator.rb was never updated to reflect this.

Also there are quotes in the code from that commit
{code}

+    # For now, leave the 'name' method functioning like it used to.  Once 'title'
+    # works everywhere, I'll switch it.
{code}

Currently:
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type.rb#L2535-L2543

Would it be safe to switch it now after 12 years?

Rob Braden (JIRA)

unread,
Aug 8, 2018, 8:15:02 PM8/8/18
to puppe...@googlegroups.com
Rob Braden updated an issue
Change By: Rob Braden
Team: Platform Core Coremunity
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (Jira)

unread,
Jun 11, 2020, 11:17:03 AM6/11/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Labels: composite-namevars
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages