Skip to content

Commit 9577d3a

Browse files
lakjamtur01
authored andcommitted
Fixing #2013 - prefetching had a mismatch between type and title
The ParsedFile types seem to be the main one that suffers from this, but the transactions were using the resource titles, not names, so resources were often not getting prefetched correctly. Signed-off-by: Luke Kanies <[email protected]>
1 parent 719a8df commit 9577d3a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/puppet/transaction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def prefetch
480480
@catalog.vertices.each do |resource|
481481
if provider = resource.provider and provider.class.respond_to?(:prefetch)
482482
prefetchers[provider.class] ||= {}
483-
prefetchers[provider.class][resource.title] = resource
483+
prefetchers[provider.class][resource.name] = resource
484484
end
485485
end
486486

spec/unit/transaction.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44

55
require 'puppet/transaction'
66

7+
describe Puppet::Transaction do
8+
it "should match resources by name, not title, when prefetching" do
9+
@catalog = Puppet::Node::Catalog.new
10+
@transaction = Puppet::Transaction.new(@catalog)
11+
12+
# Have both a title and name
13+
resource = Puppet::Type.type(:sshkey).create :title => "foo", :name => "bar", :type => :dsa, :key => "eh"
14+
@catalog.add_resource resource
15+
16+
resource.provider.class.expects(:prefetch).with("bar" => resource)
17+
18+
@transaction.prefetch
19+
end
20+
end
21+
722
describe Puppet::Transaction, " when determining tags" do
823
before do
924
@config = Puppet::Node::Catalog.new

0 commit comments

Comments
 (0)