Issue #5605 has been updated by Jesse Wolfe. Status changed from Code Insufficient to Investigating
Stefan, you're 100% right - that would be the ideal situation. I'm going to spend some time today trying to see if I can get prefetch to use uniqueness_key - I started looking into it yesterday, and it wasn't as straightforward as I imagined. If I can't get it working, I'll merge in your original patch - better to have something that works as a stopgap than to leave the system broken. ---------------------------------------- Bug #5605: Prefetch doesnt work when resourcetype uses composite keys https://projects.puppetlabs.com/issues/5605 Author: Stefan Schulte Status: Investigating Priority: Normal Assignee: Stefan Schulte Category: transactions Target version: Statler Affected Puppet version: 2.6.0 Keywords: transaction, prefetch, provider Branch: https://github.com/stschulte/puppet/tree/ticket/2.6.x/5605 One can create types with multiple keyattributes by using isnamevar multiple times. (Example: Port in /etc/services with the keyattributes name and protocol). Unfortunately prefetching of these types is broken in transaction.rb def prefetch prefetchers = {} @catalog.vertices.each do |resource| if provider = resource.provider and provider.class.respond_to?(:prefetch) prefetchers[provider.class] ||= {} prefetchers[provider.class][resource.name] = resource end end [...] end Because `resource.name` is not uniq anymore we will eventually overwrite existing resources in the prefetch-hash and thus not all resources are passed to the prefetch method of the underlying provider. So if the user defined the following manifest: port { 'telnet:tcp': name => 'telnet', protocol => 'tcp', number => '23'} port { 'telnet:udp': name => 'telnet', protocol => 'udp', number => '23'} The providers defined `def self.prefetch(resources)` will only get `resources['telnet'] = <second resource with protocol udp>` I have the following suggestions: * use `resource.uniqueness_key` instead of `resource.name`. `uniqueness_key` is an array of all the key_attributes. This can only work if you can reliably use arrays as hashkeys. I don't know if thats true for all ruby versions. This solution will probably break every existing provider who uses prefetch * same as firstone except use uniqueness_key[0].intern if we only have one keyattribute. This solution will hopefully not break existing providers * use `prefetchers[provider.class][resource.name] << resource` so we will not overwrite but build an array if name is not uniq. * build a nested hash, so in my port example we whould get `prefetchers[provider.class][resource[:name]][resource[:protocol]]` -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
