As it stands, if condormatic_classads_sync throws an exception,
it will just continue failing in a fast loop, filling up the
logs. To prevent that, re-order the loop. First, do a
classads_sync when we first come up; if it fails, continue
on anyway because later ones might succeed. Next, take the
select out of the begin..rescue block; if select fails, there
is not a whole lot we can do and we should exit. Finally,
but condormatic_classads_sync at the bottom of the loop.
That way, if it throws an exception, we'll go back to the
top of the loop and do another sleep on select.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/condor_refreshd/condor_refreshd | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/condor_refreshd/condor_refreshd b/src/condor_refreshd/condor_refreshd
index 1a02665..4991083 100755
--- a/src/condor_refreshd/condor_refreshd
+++ b/src/condor_refreshd/condor_refreshd
@@ -96,11 +96,22 @@ begin
open(REFRESHD_PID_FILE, "w") {|f| f.write(Process.pid) }
File.chmod(0644, REFRESHD_PID_FILE)
+ begin
+ condormatic_classads_sync
+ logger.info "Initial classads sync successful"
+ rescue => e
+ # if the first classads_sycn failed, just log it and go on. Subsequent
+ # ones might succeed
+ logger.error "Initial classads sycn failed, continuing anyway"
+ end
+
while true
- begin
- condormatic_classads_sync
- results = select([socket], nil, nil, timeout * 60)
+ # we do the select outside of the begin..rescue block. That way if
+ # somehow the socket fails, we won't start filling the logs by continually
+ # trying to select on a bogus socket, and instead we will exit
+ results = select([socket], nil, nil, timeout * 60)
+ begin
# 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
@@ -109,6 +120,8 @@ begin
else
logger.info "Doing classad sync after timeout"
end
+
+ condormatic_classads_sync
rescue => e
logger.error "#{e.backtrace.shift}: #{e.message}"
e.backtrace.each do |step|
--
1.7.4.2