diff options
| author | Luke Kanies <luke@madstop.com> | 2007-09-07 10:58:07 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-09-07 10:58:07 -0500 |
| commit | ca57c793d4f1ad249f63f26609be2fa9208ca244 (patch) | |
| tree | 61fdc868bb4637c3661f79fa6fdf74443ed6da86 | |
| parent | caad11a9d15210017f75918b50184bc12f2cc1d0 (diff) | |
| download | puppet-ca57c793d4f1ad249f63f26609be2fa9208ca244.tar.gz puppet-ca57c793d4f1ad249f63f26609be2fa9208ca244.tar.xz puppet-ca57c793d4f1ad249f63f26609be2fa9208ca244.zip | |
Fixing #801 -- resources that have changes when running in noop mode do not record that they were checked, so that they will be scheduled on the next run. This is a somewhat murky solution, but considering that no one had submitted this bug before, I expect it will not hit many people.
| -rw-r--r-- | lib/puppet/metatype/evaluation.rb | 11 | ||||
| -rwxr-xr-x | test/ral/manager/type.rb | 21 |
2 files changed, 29 insertions, 3 deletions
diff --git a/lib/puppet/metatype/evaluation.rb b/lib/puppet/metatype/evaluation.rb index 4b8d293c4..b358fefad 100644 --- a/lib/puppet/metatype/evaluation.rb +++ b/lib/puppet/metatype/evaluation.rb @@ -29,7 +29,16 @@ class Puppet::Type self.debug "%s change(s)" % [changes.length] end - self.cache(:checked, Time.now) + + # If we're in noop mode, we don't want to store the checked time, + # because it will result in the resource not getting scheduled if + # someone were to run the configuration in non-noop mode. + # We're going to go ahead and record that we checked if there were + # no changes, since it's unlikely it will affect the scheduling. + noop = noop? + if ! noop or (noop && changes.length == 0) + self.cache(:checked, Time.now) + end return changes.flatten end diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb index cbe969fb3..292d66b28 100755 --- a/test/ral/manager/type.rb +++ b/test/ral/manager/type.rb @@ -815,6 +815,23 @@ class TestType < Test::Unit::TestCase end end end -end -# $Id$ + # #801 -- resources only checked in noop should be rescheduled immediately. + def test_reschedule_when_noop + Puppet::Type.type(:schedule).mkdefaultschedules + file = Puppet::Type.type(:file).create(:path => "/tmp/whatever", :mode => "755", :noop => true, :schedule => :daily, :ensure => :file) + + assert(file.noop?, "File not considered in noop") + assert(file.scheduled?, "File is not considered scheduled") + + file.evaluate + + assert_nil(file.cached(:checked), "Stored a checked time when running in noop mode when there were changes") + file.cache(:checked, nil) + + file.stubs(:propertychanges).returns([]) + + file.evaluate + assert_instance_of(Time, file.cached(:checked), "Did not store a checked time when running in noop mode when there were no changes") + end +end |
