From fcfc81806c6e801d7c7597a8df245e08e15106ff Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 4 Feb 2019 16:36:02 -0500 Subject: [PATCH] Skip the database check filtering if not present, such as on warnings --- health/healthcheck.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/health/healthcheck.py b/health/healthcheck.py index a449eba50..70bec40f9 100644 --- a/health/healthcheck.py +++ b/health/healthcheck.py @@ -120,6 +120,8 @@ class LocalHealthCheck(HealthCheck): class RDSAwareHealthCheck(HealthCheck): def __init__(self, app, config_provider, instance_keys, access_key, secret_key, db_instance='quay', region='us-east-1'): + # Note: We skip the redis check because if redis is down, we don't want ELB taking the + # machines out of service. Redis is not considered a high avaliability-required service. super(RDSAwareHealthCheck, self).__init__(app, config_provider, instance_keys, [ 'redis', 'storage']) @@ -133,23 +135,22 @@ class RDSAwareHealthCheck(HealthCheck): return ['RDSAwareHealthCheck', 'ProductionHealthCheck'] def get_instance_health(self, service_statuses): - # Note: We skip the redis check because if redis is down, we don't want ELB taking the - # machines out of service. Redis is not considered a high avaliability-required service. skip = [] notes = [] # If the database is marked as unhealthy, check the status of RDS directly. If RDS is # reporting as available, then the problem is with this instance. Otherwise, the problem is # with RDS, and so we skip the DB status so we can keep this machine as 'healthy'. - db_healthy = service_statuses['database'] - if not db_healthy: - rds_status = self._get_rds_status() - notes.append('DB reports unhealthy; RDS status: %s' % rds_status) + if 'database' in service_statuses: + db_healthy = service_statuses['database'] + if not db_healthy: + rds_status = self._get_rds_status() + notes.append('DB reports unhealthy; RDS status: %s' % rds_status) - # If the RDS is in any state but available, then we skip the DB check since it will - # fail and bring down the instance. - if rds_status != 'available': - skip.append('database') + # If the RDS is in any state but available, then we skip the DB check since it will + # fail and bring down the instance. + if rds_status != 'available': + skip.append('database') return self.calculate_overall_health(service_statuses, skip=skip, notes=notes)