diff options
author | Mattia Rizzolo <mattia@mapreri.org> | 2015-02-09 01:54:27 +0100 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2015-02-09 02:01:32 +0100 |
commit | 8f64f792cb07b0e88fa6ffa7686401c1ae5870a8 (patch) | |
tree | 14f576a6c0642f53b47c03a2b3760acdbbdb110e /bin | |
parent | 23f6db1522c08ef6a9dc1cd309d01bdec54f31ee (diff) | |
download | jenkins.debian.net-8f64f792cb07b0e88fa6ffa7686401c1ae5870a8.tar.xz |
reproducible: UDD is not critical in this infrastucture, let it fail nicely as much as possible
In particular:
* missing network connection is fine
* errors on the udd part are fine
* quite everything is fine
just, every query will cause a fake empty response, and this will be logged as error.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/reproducible_common.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index 6fe0a549..dbc52ca7 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -16,6 +16,7 @@ import logging import argparse import datetime import psycopg2 +from traceback import print_exception from string import Template DEBUG = False @@ -221,14 +222,32 @@ def start_udd_connection(): " host=" + host + " password=" + password) except: - print_critical_message("Erorr connecting to the UDD database replica") - raise + log.error('Erorr connecting to the UDD database replica.' + + 'The full error is:') + exc_type, exc_value, exc_traceback = sys.exc_info() + print_exception(exc_type, exc_value, exc_traceback) + log.error('Failing nicely anyway, all queries will return an empty ' + + 'response.') + return None conn.set_client_encoding('utf8') return conn def query_udd(query): + if not conn_udd: + log.error('There has been an error connecting to the UDD database. ' + + 'Please look for a previous error for more information.') + log.error('Failing nicely anyway, returning an empty response.') + return [] cursor = conn_udd.cursor() - cursor.execute(query) + try: + cursor.execute(query) + except: + log.error('The UDD server encountered a issue while executing the ' + + 'query. The full error is:') + exc_type, exc_value, exc_traceback = sys.exc_info() + print_exception(exc_type, exc_value, exc_traceback) + log.error('Failing nicely anyway, returning an empty response.') + return [] return cursor.fetchall() def is_virtual_package(package): |