From 8f64f792cb07b0e88fa6ffa7686401c1ae5870a8 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Mon, 9 Feb 2015 01:54:27 +0100 Subject: 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. --- bin/reproducible_common.py | 25 ++++++++++++++++++++++--- 1 file 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): -- cgit v1.2.3-70-g09d2