diff options
author | Rob Austein <sra@hactrn.net> | 2015-11-12 00:36:51 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-11-12 00:36:51 +0000 |
commit | dd55d982548d76837e4a68331b2da3d973606f59 (patch) | |
tree | 9131bbf6ec610027ec5c054f28f523db477c19aa | |
parent | 09b20bf0236e78bf7dd0e61d674b3c56454c82b3 (diff) |
More useful log messages on PDU handling exceptions.
Tweak publication callback mechanism to use uri instead of tag.
svn path=/branches/tk705/; revision=6169
-rw-r--r-- | rpki/pubd.py | 4 | ||||
-rw-r--r-- | rpki/rpkid.py | 4 | ||||
-rw-r--r-- | rpki/rpkidb/models.py | 20 |
3 files changed, 15 insertions, 13 deletions
diff --git a/rpki/pubd.py b/rpki/pubd.py index ee258f26..3ae8645a 100644 --- a/rpki/pubd.py +++ b/rpki/pubd.py @@ -205,7 +205,7 @@ class main(object): r_pdu.set("tag", q_pdu.get("tag")) except Exception, e: - logger.exception("Exception processing PDU %r", q_pdu) + logger.exception("Exception processing PDU %r action = %s client_handle = %s", q_pdu, q_pdu.get("action"), q_pdu.get("client_handle")) r_pdu = SubElement(r_msg, rpki.publication_control.tag_report_error, error_code = e.__class__.__name__) r_pdu.text = str(e) if q_pdu.get("tag") is not None: @@ -278,7 +278,7 @@ class main(object): self.session.expire_deltas() except Exception, e: - logger.exception("Exception processing PDU %r", q_pdu) + logger.exception("Exception processing PDU %r hash = %s uri = %s", q_pdu, q_pdu.get("hash"), q_pdu.get("uri")) r_pdu = SubElement(r_msg, rpki.publication.tag_report_error, error_code = e.__class__.__name__) r_pdu.text = str(e) if q_pdu.get("tag") is not None: diff --git a/rpki/rpkid.py b/rpki/rpkid.py index 96f3426f..ceac39f4 100644 --- a/rpki/rpkid.py +++ b/rpki/rpkid.py @@ -719,9 +719,7 @@ class publication_queue(object): pdu.set("hash", pdu_hash) if handler is not None: - tag = str(id(pdu)) - self.handlers[tag] = handler - pdu.set("tag", tag) + self.handlers[uri] = handler if self.replace: self.uris[uri] = pdu diff --git a/rpki/rpkidb/models.py b/rpki/rpkidb/models.py index d63950ea..d3bbbfa5 100644 --- a/rpki/rpkidb/models.py +++ b/rpki/rpkidb/models.py @@ -477,25 +477,28 @@ class Repository(models.Model): @tornado.gen.coroutine - def call_pubd(self, rpkid, q_msg, handlers = {}, length_check = True): # pylint: disable=W0102 + def call_pubd(self, rpkid, q_msg, handlers = None, length_check = True): """ Send a message to publication daemon and return the response. As a convenience, attempting to send an empty message returns immediate success without sending anything. - handlers is a dict of handler functions to process the response - PDUs. If the tag value in the response PDU appears in the dict, - the associated handler is called to process the PDU. If no tag - matches, a default handler is called to check for errors; a - handler value of False suppresses calling of the default handler. + handlers is a dict of handler functions to process the + response PDUs. If the uri value in the response PDU appears + in the dict, the associated handler is called to process the + PDU; otherwise, a default handler is called to check for + errors. A handler value of False suppresses calling of the + default handler. """ trace_call_chain() if len(q_msg) == 0: return + if handlers is None: + handlers = {} for q_pdu in q_msg: - logger.info("Sending %r to pubd", q_pdu) + logger.info("Sending %r hash = %s uri = %s to pubd", q_pdu, q_pdu.get("hash"), q_pdu.get("uri")) http_request = tornado.httpclient.HTTPRequest( url = self.peer_contact_uri, method = "POST", @@ -510,7 +513,8 @@ class Repository(models.Model): r_msg = r_cms.unwrap((rpkid.bpki_ta, self.tenant.bpki_cert, self.tenant.bpki_glue, self.bpki_cert, self.bpki_glue)) r_cms.check_replay_sql(self, self.peer_contact_uri) for r_pdu in r_msg: - handler = handlers.get(r_pdu.get("tag"), rpki.publication.raise_if_error) + logger.info("Received %r hash = %s uri = %s from pubd", r_pdu, r_pdu.get("hash"), r_pdu.get("uri")) + handler = handlers.get(r_pdu.get("uri"), rpki.publication.raise_if_error) if handler: logger.debug("Calling pubd handler %r", handler) handler(r_pdu) |