aboutsummaryrefslogtreecommitdiff
path: root/rpki/rpkidb
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-10-23 21:42:06 +0000
committerRob Austein <sra@hactrn.net>2015-10-23 21:42:06 +0000
commit07dfb053fc4602c9be7927a6259ae07074cfbf4c (patch)
treeefe7cd7c0dac6d06890a4c90653af055a50ad49e /rpki/rpkidb
parentd97d997b135005d7c71d07e3befaef71789b8b06 (diff)
Task system now working with Tornado. Two new problems: some kind of
UTF-8 whining on what are supposed to be binary fields that's probably the result of a MySQL upgrade, and CMS Replay exceptions due to the pseudo-random order in which HTTP client connections run in Tornado. The UTF-8 mess is probably a good reason to change over to Django's native binary field type, which we were going to want to do anyway. The CMS Replay problem is not Tornado's fault: we probably would have seen it in the old code were it not for an accidental side effect of a long-since-abandoned attempt to use persistent HTTP connections. The fix is probably to serialize requests to a particular host using use a tornaodo.queue.Queue() object, or something like that. svn path=/branches/tk705/; revision=6143
Diffstat (limited to 'rpki/rpkidb')
-rw-r--r--rpki/rpkidb/models.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/rpki/rpkidb/models.py b/rpki/rpkidb/models.py
index 2693064a..852c8957 100644
--- a/rpki/rpkidb/models.py
+++ b/rpki/rpkidb/models.py
@@ -334,27 +334,19 @@ class Tenant(models.Model):
@tornado.gen.coroutine
def serve_run_now(self, rpkid):
logger.debug("Forced immediate run of periodic actions for tenant %s[%r]", self.tenant_handle, self)
- futures = [condition.wait() for condition in self.schedule_cron_tasks(rpkid)]
+ tasks = self.cron_tasks(rpkid)
+ rpkid.task_add(tasks)
+ futures = [task.wait() for task in tasks]
rpkid.task_run()
- logger.debug("serve_run_now() futures: %r", futures)
- assert futures
- try:
- yield futures
- except:
- logger.exception("serve_run_now() failed")
- raise
- else:
- logger.debug("serve_run_now() done")
+ yield futures
- def schedule_cron_tasks(self, rpkid):
+ def cron_tasks(self, rpkid):
try:
- tasks = self.cron_tasks
+ return self._cron_tasks
except AttributeError:
- tasks = self.cron_tasks = tuple(task(rpkid, self) for task in rpki.rpkid_tasks.task_classes)
- for task in tasks:
- rpkid.task_add(task)
- yield task.completed # Plain old Python generator yield, this is not a coroutine
+ self._cron_tasks = tuple(task(rpkid, self) for task in rpki.rpkid_tasks.task_classes)
+ return self._cron_tasks
def find_covering_ca_details(self, resources):
@@ -451,7 +443,7 @@ class Repository(models.Model):
"""
if len(q_msg) == 0:
- raise tornado.gen.Return
+ return
for q_pdu in q_msg:
logger.info("Sending %r to pubd", q_pdu)
@@ -781,7 +773,7 @@ class CA(models.Model):
logger.warning("Existing resource class %s to %s from %s with no certificates, rekeying",
class_name, parent.tenant.tenant_handle, parent.parent_handle)
yield self.rekey(rpkid)
- raise tornado.gen.Return
+ return
for ca_detail in ca_details:
@@ -1199,7 +1191,7 @@ class CADetail(models.Model):
if self.state == "pending":
yield self.activate(rpkid = rpkid, ca = ca, cert = cert, uri = cert_url)
- raise tornado.gen.Return
+ return
validity_changed = self.latest_ca_cert is None or self.latest_ca_cert.getNotAfter() != cert.getNotAfter()