XD-DENG commented on a change in pull request #4309: [AIRFLOW-3504] 
Extend/refine the functionality of "/health" endpoint
URL: https://github.com/apache/airflow/pull/4309#discussion_r246398964
 
 

 ##########
 File path: airflow/www_rbac/views.py
 ##########
 @@ -147,6 +147,33 @@ def render(self, template, **context):
 
 
 class Airflow(AirflowBaseView):
+    @expose('/health')
+    @provide_session
+    def health(self, session=None):
+        from sqlalchemy import func
+        DM = models.DagModel
+        payload = {}
+
+        latest_scheduler_run = None
+        payload['metadatabase'] = {'status': 'healthy'}
+        try:
+            latest_scheduler_run = 
session.query(func.max(DM.last_scheduler_run)).scalar()
+        except Exception as _:
+            payload['metadatabase']['status'] = 'unhealthy'
+
+        if not latest_scheduler_run:
+            scheduler_status = 'unhealthy'
+        else:
+            if timezone.utcnow() - latest_scheduler_run <= 
timedelta(seconds=30):
 
 Review comment:
   Addressed. Now it's a configuration item

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to