From e392add46fc09c86a7738ad5138a8b445b8eb566 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 1 Jun 2015 15:58:28 -0400 Subject: [PATCH] Catch exceptions if there are issues communicating with mongo --- awx/main/management/commands/run_fact_cache_receiver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/management/commands/run_fact_cache_receiver.py b/awx/main/management/commands/run_fact_cache_receiver.py index e302924992..ec16f0a4f2 100644 --- a/awx/main/management/commands/run_fact_cache_receiver.py +++ b/awx/main/management/commands/run_fact_cache_receiver.py @@ -10,6 +10,7 @@ from awx.fact.models.fact import * # noqa from awx.main.socket import Socket logger = logging.getLogger('awx.main.commands.run_fact_cache_receiver') + class FactCacheReceiver(object): def __init__(self): self.timestamp = None @@ -48,7 +49,10 @@ class FactCacheReceiver(object): host.save() except FactHost.MultipleObjectsReturned: query = "db['fact_host'].find(hostname=%s)" % hostname - print('Database inconsistent. Multiple FactHost "%s" exist. Try the query %s to find the records.' % (hostname, query)) + logger.warn('Database inconsistent. Multiple FactHost "%s" exist. Try the query %s to find the records.' % (hostname, query)) + return + except Exception, e: + logger.error("Exception communicating with Mongo: %s" % str(e)) return (module, facts) = self.process_facts(facts_data)