One of the problems with this model, though, is that there's a semantic 
difference between writing the file out and not - if you've got a service that 
needs to get restarted if the file changes, but not if it doesn't, then you 
can't just write it out every time.

On Dec 16, 2010, at 7:49 PM, Trevor Vaughan wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I disagree.
> 
> Look at the concat module. Why waste resources checksumming when it
> would be more efficient to just write out the file?
> 
> Read + Checksum + (potential) Write is more I/O and CPU intensive than
> Write.
> 
> Trevor
> 
> On 12/16/2010 07:25 PM, Nigel Kersten wrote:
>> On Thu, Dec 16, 2010 at 2:55 PM, Jesse A Wolfe <[email protected]> wrote:
>>> 
>>>> What's the behavior with this patch when checksum=none and specifying a
>>>> source or content?  How does the system compare the current file to the
>>>> desired file?
>>> 
>>> It overwrites the file every time. That might not be the most desirable
>>> behavior, but it's more correct than *truncating* the file every time.
>> 
>> Note that we changed the desired behavior to fail with a syntax error 
>> instead.
>> 
>> It doesn't make sense to not checksum and specify content/source.
>> 
>>> 
>>>> 
>>>> On Dec 16, 2010, at 2:41 PM, Jesse Wolfe wrote:
>>>> 
>>>>> The #write method in lib/puppet/type/file/content.rb relies on the block
>>>>> passed to #sum_stream getting executed.  "none", "mtime", and "ctime"
>>>>> aren't real checksums, so they violated that assumption and just
>>>>> returned empty results.  This patch causes that block to get executed.
>>>>> 
>>>>> Signed-off-by: Jesse Wolfe <[email protected]>
>>>>> ---
>>>>> lib/puppet/util/checksums.rb     |   11 +++++++++++
>>>>> spec/unit/util/checksums_spec.rb |   10 +++++++++-
>>>>> 2 files changed, 20 insertions(+), 1 deletions(-)
>>>>> 
>>>>> diff --git a/lib/puppet/util/checksums.rb b/lib/puppet/util/checksums.rb
>>>>> index 5aebd83..6fdf14e 100644
>>>>> --- a/lib/puppet/util/checksums.rb
>>>>> +++ b/lib/puppet/util/checksums.rb
>>>>> @@ -1,6 +1,12 @@
>>>>> # A stand-alone module for calculating checksums
>>>>> # in a generic way.
>>>>> module Puppet::Util::Checksums
>>>>> +  class FakeChecksum
>>>>> +    def <<(*args)
>>>>> +      self
>>>>> +    end
>>>>> +  end
>>>>> +
>>>>>  # Is the provided string a checksum?
>>>>>  def checksum?(string)
>>>>>    string =~ /^\{(\w{3,5})\}\S+/
>>>>> @@ -55,7 +61,10 @@ module Puppet::Util::Checksums
>>>>>  end
>>>>> 
>>>>>  # by definition this doesn't exist
>>>>> +  # but we still need to execute the block given
>>>>>  def mtime_stream
>>>>> +    noop_digest = FakeChecksum.new
>>>>> +    yield noop_digest
>>>>>    nil
>>>>>  end
>>>>> 
>>>>> @@ -105,6 +114,8 @@ module Puppet::Util::Checksums
>>>>>  end
>>>>> 
>>>>>  def none_stream
>>>>> +    noop_digest = FakeChecksum.new
>>>>> +    yield noop_digest
>>>>>    ""
>>>>>  end
>>>>> 
>>>>> diff --git a/spec/unit/util/checksums_spec.rb
>>>>> b/spec/unit/util/checksums_spec.rb
>>>>> index e018581..a8bc12b 100755
>>>>> --- a/spec/unit/util/checksums_spec.rb
>>>>> +++ b/spec/unit/util/checksums_spec.rb
>>>>> @@ -140,7 +140,9 @@ describe Puppet::Util::Checksums do
>>>>>      end
>>>>> 
>>>>>      it "should return nil for streams" do
>>>>> -        @summer.send(sum.to_s + "_stream").should be_nil
>>>>> +        expectation = stub "expectation"
>>>>> +        expectation.expects(:do_something!).at_least_once
>>>>> +        @summer.send(sum.to_s + "_stream"){ |checksum| checksum <<
>>>>> "anything" ; expectation.do_something!  }.should be_nil
>>>>>      end
>>>>>    end
>>>>>  end
>>>>> @@ -149,5 +151,11 @@ describe Puppet::Util::Checksums do
>>>>>    it "should return an empty string" do
>>>>>      @summer.none_file("/my/file").should == ""
>>>>>    end
>>>>> +
>>>>> +    it "should return an empty string for streams" do
>>>>> +      expectation = stub "expectation"
>>>>> +      expectation.expects(:do_something!).at_least_once
>>>>> +      @summer.none_stream{ |checksum| checksum << "anything" ;
>>>>> expectation.do_something!  }.should == ""
>>>>> +    end
>>>>>  end
>>>>> end
>>>>> --
>>>>> 1.7.0.4
>>>>> 
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Puppet Developers" 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-dev?hl=en.
>>>>> 
>>>> 
>>>> 
>>>> --
>>>> If you can't be a good example, then you'll just have to be a
>>>> horrible warning.                -- Catherine Aird
>>>> ---------------------------------------------------------------------
>>>> Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199
>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "Puppet Developers" 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-dev?hl=en.
>>>> 
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Puppet Developers" 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-dev?hl=en.
>>> 
>> 
>> 
>> 
> 
> - -- 
> Trevor Vaughan
> Vice President, Onyx Point, Inc.
> email: [email protected]
> phone: 410-541-ONYX (6699)
> pgp: 0x6C701E94
> 
> - -- This account not approved for unencrypted sensitive information --
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> 
> iQEcBAEBAgAGBQJNCt2wAAoJECNCGV1OLcypTUUH/2u7rEHoqZAkjelGMk2+foJC
> nyPIRS3bC5Tar6j29PFbyOJgH63+Y85g0a1tz6PU5U63Hi43EbapnSrqMq+UCzpc
> oAlaFe1vaLXm9V6Bab8XS1w33VEHBHpaGTe/0HTUj9sPVrWqIlLa38MLQvtyOokV
> eYaybLBgQpAbfYCl8H/8+4GrxcaMFD0JM7G84XMB2DJhLBEGe04lEHvP5rxC260G
> Mm6ofMQUREktKyrHAYqPlXEVKstKrjlyzKHEXiLRrtoV12PicPs9FlIK3ChSNsgz
> aId9Nl9Y5UAYu9NBiFSu0CpawkxSBlS8tFoIOLHJq1DWHbKiyWsqB0oHjrA6mDo=
> =j/ll
> -----END PGP SIGNATURE-----
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" 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-dev?hl=en.
> 
> <tvaughan.vcf>


-- 
If two men agree on everything, you may be sure that one of them is
doing the thinking.    -- Lyndon B. Johnson
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199




-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" 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-dev?hl=en.

Reply via email to