From dbd119c365a5c61b910f48e4894df3390140af64 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 20 May 2015 17:40:43 -0400 Subject: [PATCH] Fix the DB health check Make sure to search for the proper DB identifier --- health/healthcheck.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/health/healthcheck.py b/health/healthcheck.py index 11a365e34..98de22435 100644 --- a/health/healthcheck.py +++ b/health/healthcheck.py @@ -77,10 +77,11 @@ class LocalHealthCheck(HealthCheck): class ProductionHealthCheck(HealthCheck): - def __init__(self, app, access_key, secret_key): + def __init__(self, app, access_key, secret_key, db_instance='quay'): super(ProductionHealthCheck, self).__init__(app) self.access_key = access_key self.secret_key = secret_key + self.db_instance = db_instance @classmethod def check_name(cls): @@ -115,7 +116,10 @@ class ProductionHealthCheck(HealthCheck): aws_access_key_id=self.access_key, aws_secret_access_key=self.secret_key) response = region.describe_db_instances()['DescribeDBInstancesResponse'] result = response['DescribeDBInstancesResult'] - instances = result['DBInstances'] + instances = [i for i in result['DBInstances'] if i['DBInstanceIdentifier'] == self.db_instance] + if not instances: + return 'error' + status = instances[0]['DBInstanceStatus'] return status except: