Fix the DB health check
Make sure to search for the proper DB identifier
This commit is contained in:
parent
5845e37e32
commit
dbd119c365
1 changed files with 6 additions and 2 deletions
|
@ -77,10 +77,11 @@ class LocalHealthCheck(HealthCheck):
|
||||||
|
|
||||||
|
|
||||||
class ProductionHealthCheck(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)
|
super(ProductionHealthCheck, self).__init__(app)
|
||||||
self.access_key = access_key
|
self.access_key = access_key
|
||||||
self.secret_key = secret_key
|
self.secret_key = secret_key
|
||||||
|
self.db_instance = db_instance
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_name(cls):
|
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)
|
aws_access_key_id=self.access_key, aws_secret_access_key=self.secret_key)
|
||||||
response = region.describe_db_instances()['DescribeDBInstancesResponse']
|
response = region.describe_db_instances()['DescribeDBInstancesResponse']
|
||||||
result = response['DescribeDBInstancesResult']
|
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']
|
status = instances[0]['DBInstanceStatus']
|
||||||
return status
|
return status
|
||||||
except:
|
except:
|
||||||
|
|
Reference in a new issue