Commit 4deac149 authored by Kirk Webb's avatar Kirk Webb
Browse files

Update to libplab.plab.renew:

  * Make renewal robust against various kinds of failures.  These changes
    will augment my larger set of libplab and plab* updates/fixes coming
    soon to an Emulab near you.
parent 82edbdde
......@@ -30,6 +30,7 @@ import traceback
LEASELEN = 14*24*60*60 # Two weeks (maximum lease length)
RENEW_TIME = 2*24*60*60 # Renew two days before lease expires
RENEW_TIMEOUT = 1*60 # Give the node 1 minute to respond
TBOPS = "@TBOPSEMAIL@".replace("\\","")
......@@ -590,11 +591,17 @@ class Plab:
# Ugh, MySQL doesn't know UTC until v4.1.1, and unix_timestamp()
# returns the local time
import time
from signal import signal, alarm, SIGALRM
from traceback import format_exception_only
from xmlrpclib import Fault
endtime = int(time.mktime(time.gmtime())) + RENEW_TIME
res = DBQueryFatal("select pid, eid, node_id from plab_slice_nodes"
" where %s > unix_timestamp(leaseend)",
(endtime, ))
loadedSlices = {}
class TimeoutError(StandardError): pass
def alrmhandler(signum, frame): raise TimeoutError
signal(SIGALRM, alrmhandler)
for pid, eid, nodeid in res:
slice = loadedSlices[(pid, eid)]
......@@ -602,7 +609,19 @@ class Plab:
slice = self.loadSlice(pid, eid)
loadedSlices[(pid, eid)] = slice
node = slice.loadNode(nodeid)
except TimeoutError:
print "Timeout waiting for renewal of sliver %s" % nodeid
except Fault, e:
print "Got XMLRPC fault while renewing %s:\n\t%s" % \
(nodeid, e.faultString)
tb = "".join(format_exception_only(*sys.exc_info()[:2]))
print "unknown exception while trying to renew %s\n%s" % \
(nodeid, tb)
def _createAgentProxy(self, insecure = False):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment