mistercrunch closed pull request #4062: [health] Adding DB check to /health
URL: https://github.com/apache/incubator-superset/pull/4062
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/views/core.py b/superset/views/core.py
index 00254b4ca2..88014194e5 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -28,6 +28,7 @@
 import sqlalchemy as sqla
 from sqlalchemy import create_engine
 from sqlalchemy.engine.url import make_url
+from sqlalchemy.exc import OperationalError
 from unidecode import unidecode
 from werkzeug.routing import BaseConverter
 from werkzeug.utils import secure_filename
@@ -654,6 +655,11 @@ class LogModelView(SupersetModelView):
 
 @app.route('/health')
 def health():
+    try:
+        db.session.execute('SELECT 1')
+    except OperationalError:
+        return Response('BAD', status=500)
+
     return '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:
[email protected]


With regards,
Apache Git Services

Reply via email to