In order to make some of the condor patches more palatable to upstream, they requested that we stop using the phone-home capability of condor to refresh our classads. Since we don't expect condor to restart very often, it should be sufficient to just advertise classads to condor every 15 minutes or when it is kicked. This patch just puts the socket in a select with a timeout and wakes up every 15 minutes to re-advertise.
Signed-off-by: Chris Lalancette clalance@redhat.com --- src/condor_refreshd/condor_refreshd | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/condor_refreshd/condor_refreshd b/src/condor_refreshd/condor_refreshd index 74dbb82..4f1b93c 100755 --- a/src/condor_refreshd/condor_refreshd +++ b/src/condor_refreshd/condor_refreshd @@ -31,6 +31,7 @@ help = false daemon = true refreshd_log_dir = "/var/log/deltacloud-aggregator" refreshd_pid_dir = "/var/run/deltacloud-aggregator" +timeout = 15
optparse = OptionParser.new do |opts|
@@ -50,6 +51,9 @@ BANNER opts.on( '-p', '--port PORT', 'Use PORT (default: 7890)') do |newport| port = newport end + opts.on( '-t', '--timeout TIMEOUT', 'Automatically refresh classads after TIMEOUT minutes') do |newtime| + timeout = newtime + end end
begin @@ -77,7 +81,7 @@ logger.level = Logger::DEBUG
logger.info "Starting condor_refreshd..." socket = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0) -in_addr = Socket.pack_sockaddr_in(port, '0.0.0.0') +in_addr = Socket.pack_sockaddr_in(port, '127.0.0.1') socket.bind(in_addr)
# daemonize @@ -94,9 +98,17 @@ begin
while true begin - packet = socket.recvfrom(1024) - logger.info "Doing classad sync" condormatic_classads_sync + results = select([socket], nil, nil, timeout * 60) + + # if results was nil, we timed out waiting, and we need to do a sync + # but not read from the socket + if not results.nil? and results[0][0] == socket + socket.recvfrom(1024) + logger.info "Doing classad sync after getting data from the socket" + else + logger.info "Doing classad sync after timeout" + end rescue => e logger.error "#{e.backtrace.shift}: #{e.message}" e.backtrace.each do |step|
On Thu, 2010-10-14 at 09:34 -0400, Chris Lalancette wrote:
In order to make some of the condor patches more palatable to upstream, they requested that we stop using the phone-home capability of condor to refresh our classads. Since we don't expect condor to restart very often, it should be sufficient to just advertise classads to condor every 15 minutes or when it is kicked. This patch just puts the socket in a select with a timeout and wakes up every 15 minutes to re-advertise.
Might be nice to add a kick to condor start in the init scripts or something but we can also do that by hand.
ACK
deltacloud-devel@lists.fedorahosted.org