Bug #1551

puppetmaster.freshness xmlrpc call returns incorrect type

Added by Nigel Kersten over 3 years ago. Updated almost 2 years ago.

Status:Closed Start date:09/03/2008
Priority:Normal Due date:
Assignee:Luke Kanies % Done:

0%

Category:plumbing
Target version:0.24.6
Affected Puppet version:0.24.5 Branch:
Keywords:
Votes: 0

Description

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:

undefined method `-' for #

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:

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

it fails at the line:

if newcompile - @compile_time.to_i < 1

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:

        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

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.


Related issues

related to Puppet - Bug #1505: 0.24.4 client againt 0.24.5 server error: undefined metho... Closed 08/11/2008

History

Updated by Nigel Kersten over 3 years ago

http://github.com/nigelkersten/puppetmaster/commit/65ce150b04e46cfb572d9d2682bf5d9a3b37da68

This patch works against the 0.24.x branch.

Updated by James Turnbull over 3 years ago

  • Category set to plumbing
  • Status changed from Unreviewed to Needs Decision
  • Assignee set to Luke Kanies

Updated by James Turnbull over 3 years ago

  • Status changed from Needs Decision to Closed

Pushed in commit:e15d316cbb9ee33bfbed4b29649f36a97490e985 in branch 0.24.x

Also available in: Atom PDF