Issue #5605 has been updated by Jesse Wolfe. Status changed from Investigating to Code Insufficient Assignee changed from Stefan Schulte to Paul Berry
OK: I'm not satisfied that I can get this working before I leave on vacation. I really wanted to merge your submitted version as a fallback (in fact I actually did, and reverted it), but collapsing uniqueness_key into a string value instead of an array causes a regression in lib/puppet/resource/catalog.rb, where names and titles collide in alias-space. I'm handing this off to Paul Berry. ---------------------------------------- Bug #5605: Prefetch doesnt work when resourcetype uses composite keys https://projects.puppetlabs.com/issues/5605 Author: Stefan Schulte Status: Code Insufficient Priority: Normal Assignee: Paul Berry 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.
