You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2018/12/18 14:19:03 UTC

[GitHub] XD-DENG commented on a change in pull request #4309: [AIRFLOW-3504] Extend/refine the functionality of "/health" endpoint

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

 ##########
 File path: airflow/www/blueprints.py
 ##########
 @@ -32,6 +35,22 @@ def index():
 
 @routes.route('/health')
 def health():
-    """ We can add an array of tests here to check the server's health """
-    content = Markup(markdown.markdown("The server is healthy!"))
-    return content
+    session = settings.Session()
+    DM = models.DagModel
+    payload = {}
+
+    payload['webserver'] = "The server is healthy!"
+
+    payload['database'] = "available"
+    try:
+        session.query(DM).count()
+    except Exception as _:
+        payload['database'] = "unavailable"
 
 Review comment:
   Thanks @ashb .
   
   I also noticed that people use status code to indicate the health check result in some applications. But the case here may be a bit different: Let's say webserver & database connection are both healthy, while scheduler is not working at all. What status code should we give?
   
   So I would suggest to just give 200, and simply use the contents of the response to indicate the health of each component. Do you think it's ok?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services