Issue #1551 has been reported by nigelk2.

----------------------------------------
Bug #1551: puppetmaster.freshness xmlrpc call returns incorrect type
http://reductivelabs.com/redmine/issues/show/1551

Author: nigelk2
Status: Unreviewed
Priority: Normal
Assigned to: 
Category: 
Target version: 0.24.6
Complexity: Unknown
Affected version: 0.24.5
Keywords: 


This is the cause of other issues people have reported with running puppet 
clients < 0.24.5 against the 0.24.5 server when using the local cache. 

It was reported as the difference between running puppetd --test and running it 
as a daemon, but the issue is in fact the use of the local cache.

Clients will report errors like this:
<pre>
undefined method `-' for #<XMLRPC::DateTime:0x1a017c4>
</pre>
The problem is that the puppetmaster.freshness XMLRPC call in 0.24.5 is 
returning Time.now which is not an integer and so when older clients call this 
method from network/client/master.rb:
<pre>
def fresh?(facts)
        if Puppet[:ignorecache]
            Puppet.notice "Ignoring cache"
            return false
        end
        unless self.compile_time
            Puppet.debug "No cached compile time"
            return false
        end
        if facts_changed?(facts)
            Puppet.info "Facts have changed; recompiling" unless local?
            return false
        end

        # We're willing to give a 2 second drift
        newcompile = @driver.freshness
        if newcompile - @compile_time.to_i < 1
            return true
        else
            Puppet.debug "Server compile time is %s vs %s" % [newcompile, 
@compile_time]
            return false
        end
    end
</pre>
it fails at the line:
<pre>
if newcompile - @compile_time.to_i < 1
</pre>
as it's trying to perform subtraction on an XMLRPC::DateTime object and an 
integer.

I was going to submit this patch to return Time.now.to_i , but then I spent 
some time debugging the older code for puppetmaster.freshness which looks like:

<pre>
        def freshness(client = nil, clientip = nil)
            if Puppet.features.rails? and Puppet[:storeconfigs]
                Puppet::Rails.connect

                host = Puppet::Rails::Host.find_or_create_by_name(client)
                host.last_freshcheck = Time.now
                if clientip and (! host.ip or host.ip == "")
                    host.ip = clientip
                end
                host.save
            end
            if defined? @interpreter
                return @interpreter.parsedate
            else
                return 0
            end
        end
</pre>

and in fact it always returned 0, so my patch will simply return 0 as well 
given that this function isn't called by newer clients and it seemed safest to 
return the same value as they were getting.

Patch coming now.


----------------------------------------
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://reductivelabs.com/redmine/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
-~----------~----~----~----~------~----~------~--~---

Reply via email to