From 001eb1f69f546fe83e5e84a22cde5576f4409558 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 14 Mar 2016 11:56:51 -0400 Subject: [PATCH] Handle a mongo OperationFailure This seems to happenw hen the database is up, allows us to connect but we don't have permission to access the objects (or they don't exist yet). --- awx/main/migrations/_system_tracking.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/awx/main/migrations/_system_tracking.py b/awx/main/migrations/_system_tracking.py index e5be20f4ef..936786609b 100644 --- a/awx/main/migrations/_system_tracking.py +++ b/awx/main/migrations/_system_tracking.py @@ -1,6 +1,7 @@ from awx.fact.models import FactVersion from mongoengine.connection import ConnectionError +from pymongo.errors import OperationFailure from django.conf import settings def drop_system_tracking_db(): @@ -11,6 +12,9 @@ def drop_system_tracking_db(): # TODO: Log this. Not a deal-breaker. Just let the user know they # may need to manually drop/delete the database. pass + except OperationFailure: + # TODO: This means the database was up but something happened when we tried to query it + return pass def migrate_facts(apps, schema_editor): Fact = apps.get_model('main', "Fact") @@ -22,6 +26,9 @@ def migrate_facts(apps, schema_editor): # TODO: Let the user know about the error. Likely this is # a new install and we just don't need to do this return (0, 0) + except OperationFailure: + # TODO: This means the database was up but something happened when we tried to query it + return (0, 0) migrated_count = 0 not_migrated_count = 0