Bug #10109
Composite keys cause Invalid parameter false error
| Status: | Closed | Start date: | 10/15/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | agent | |||
| Target version: | 2.7.10 | |||
| Affected Puppet version: | 2.7.4 | Branch: | ||
| Keywords: | ||||
| Votes: | 0 |
Description
When using a type with more than one name var (composite keys), the agent outputs an error:
err: Could not create resource file /var/lib/puppet/state/resources.txt: Invalid parameter false(false) at <filename>:<line>
This first appeared in version 2.7.4, most likely in commit:7a39ca72e64. When multiple key attributes exist, resource.name_var is false. The new write_resource_file method attempts to call Puppet::Type#[] with false which causes the Invalid parameter error.
The new resource list file should support types with composite keys.
Related issues
History
Updated by Stefan Schulte 7 months ago
The problem here is that we can map a resource title to different namevars (with the title_pattern method) but puppet has no way to do a backward mapping and looking at the diffs that you attached this seems to be the problem here.
Dan Bode did some work on this topic see the discussion here and an experimental patchset which introduces a namevar_join method here but I guess none of it made it into core. There are still some other problems when it comes to multiple namevars (#5605),
Updated by Joshua Lifton 6 months ago
Added Dan Bode as a watcher.
Updated by Max Martin 5 months ago
- Status changed from Unreviewed to Accepted
- Assignee set to Max Martin
I have a patch that I believe will resolve this; I’ll discuss it with Matt (who wrote the original resourcefile patch) tomorrow. Thanks for the thorough bug report!
Updated by Max Martin 5 months ago
- Status changed from Accepted to Needs More Information
- Assignee changed from Max Martin to Brandon Turner
Hi Brandon,
I have a branch up on my github that ought to fix this issue: https://github.com/MaxMartin/puppet/tree/ticket/2.7.x/10109-composite-namevars
If you could check it out and let us know whether it helps you out, that’d be great. Also, if you could tell us a bit about how you’re using composite namevars, we’re very interested, as they’re something that we haven’t really used that much yet ourselves. Thanks!
Updated by Brandon Turner 5 months ago
Max,
Thanks for working on this! I will try out the patch this weekend.
I’m using composite name vars to install RVM with puppet. You can see the module here: [[https://github.com/blt04/puppet-rvm]]
Specifically, for installing gems and gemsets in a specific Ruby version in RVM: [[https://github.com/blt04/puppet-rvm/blob/master/lib/puppet/type/rvm_gem.rb]] [[https://github.com/blt04/puppet-rvm/blob/master/lib/puppet/type/rvm_gemset.rb]]
Composite namevars allow me to use syntax like:
rvm_gem {
'ruby-1.9.2-p290/bundler':
ensure => '1.0.18',
require => Rvm_gemset['ruby-1.9.2-p290@myproject'];
}
where ruby-1.9.2-p290 is the name var :ruby_version, and bundler is the namevar :name.
Updated by Max Martin 5 months ago
Very cool use of composite namevars. Have you had a chance to check out the patch? I’d like to get it into core soon if it helped you out.
Updated by Brandon Turner 5 months ago
Max, I’m sorry it took so long to respond. Your patch did fix the problem I was having. It looks like the patch is a good fix for this ticket. Thank you!
Updated by Max Martin 5 months ago
- Status changed from Needs More Information to Merged - Pending Release
Cool, thanks for the feedback. We’ve merged the patch into 2.7.x, and are going to work on more thorough testing around composite namevars to ensure breakages like this don’t occur again.
Updated by Josh Cooper 5 months ago
- Target version set to 2.7.10
This was merged into 2.7.x in https://github.com/puppetlabs/puppet/commit/45f0855bd6be36a66acd0a28a8ed83e2d63af239
Updated by Michael Stahnke 4 months ago
- Status changed from Merged - Pending Release to Closed
released as part 2.7.10rc1