[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5rc1-120-g2247c80
Paul Berry
paul at puppetlabs.com
Mon Feb 7 06:39:59 UTC 2011
The following commit has been merged in the upstream branch:
commit 8f314f2bb14d61a2a26b67d002d90f84349b25b5
Author: Paul Berry <paul at puppetlabs.com>
Date: Fri Jan 7 15:39:52 2011 -0800
(#5710) Removed unnecessary calls to insync?
In the resource harness, we were calling insync? on all properties of
a resource, even if those properties weren't being managed. This was
unsafe. Changed to only call insync? on properties that are mentioned
in the manifest.
In addition, we discovered that the resource harness's computation of
desired_values was incorrect, and was consulting the current system
state rather than the desired state. Since this hash was
(erroneously) only being consulted to see if it included :ensure, this
didn't cause any obvious bugs. However it is now fixed.
Paired-with: Jesse Wolfe <jesse at puppetlabs.com>
diff --git a/lib/puppet/transaction/resource_harness.rb b/lib/puppet/transaction/resource_harness.rb
index c259d3e..c1b9806 100644
--- a/lib/puppet/transaction/resource_harness.rb
+++ b/lib/puppet/transaction/resource_harness.rb
@@ -37,7 +37,10 @@ class Puppet::Transaction::ResourceHarness
current_values = current.to_hash
historical_values = Puppet::Util::Storage.cache(resource).dup
- desired_values = resource.to_resource.to_hash
+ desired_values = {}
+ resource.properties.each do |property|
+ desired_values[property.name] = property.should
+ end
audited_params = (resource[:audit] || []).map { |p| p.to_sym }
synced_params = []
@@ -55,7 +58,7 @@ class Puppet::Transaction::ResourceHarness
elsif current_values[:ensure] != :absent
work_order = resource.properties # Note: only the resource knows what order to apply changes in
work_order.each do |param|
- if !param.insync?(current_values[param.name])
+ if desired_values[param.name] && !param.insync?(current_values[param.name])
events << apply_parameter(param, current_values[param.name], audited_params.include?(param.name), historical_values[param.name])
synced_params << param.name
end
diff --git a/spec/unit/transaction/resource_harness_spec.rb b/spec/unit/transaction/resource_harness_spec.rb
index f0c360e..104c19e 100755
--- a/spec/unit/transaction/resource_harness_spec.rb
+++ b/spec/unit/transaction/resource_harness_spec.rb
@@ -125,6 +125,29 @@ describe Puppet::Transaction::ResourceHarness do
end
end
+ describe "when auditing" do
+ it "should not call insync? on parameters that are merely audited" do
+ stub_provider = make_stub_provider
+ resource = stub_provider.new :name => 'name', :audit => ['foo']
+ resource.property(:foo).expects(:insync?).never
+ status = @harness.evaluate(resource)
+ status.events.each do |event|
+ event.status.should != 'failure'
+ end
+ end
+
+ it "should be able to audit a file's group" do # see bug #5710
+ test_file = tmpfile('foo')
+ File.open(test_file, 'w').close
+ resource = Puppet::Type.type(:file).new :path => test_file, :audit => ['group'], :backup => false
+ resource.expects(:err).never # make sure no exceptions get swallowed
+ status = @harness.evaluate(resource)
+ status.events.each do |event|
+ event.status.should != 'failure'
+ end
+ end
+ end
+
describe "when applying changes" do
[false, true].each do |noop_mode|; describe (noop_mode ? "in noop mode" : "in normal mode") do
[nil, '750'].each do |machine_state|; describe (machine_state ? "with a file initially present" : "with no file initially present") do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list