turbaszek commented on a change in pull request #9277:
URL: https://github.com/apache/airflow/pull/9277#discussion_r448911785



##########
File path: airflow/api_connexion/endpoints/health_endpoint.py
##########
@@ -14,13 +14,34 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-
-# TODO(mik-laj): We have to implement it.
-#     Do you want to help? Please look at: 
https://github.com/apache/airflow/issues/8144
+from airflow.api_connexion.schemas.health_schema import health_schema
+from airflow.configuration import conf
+from airflow.jobs.scheduler_job import SchedulerJob
+from airflow.utils.session import provide_session
 
 
 def get_health():
     """
-    Checks if the API works
+    Return the health of the airflow scheduler and metadatabase
     """
-    return "OK"
+    payload = {
+        'metadatabase': {'status': 'unhealthy'}
+    }
+
+    latest_scheduler_heartbeat = None
+    scheduler_status = 'unhealthy'
+    payload['metadatabase'] = {'status': 'healthy'}

Review comment:
       ```python
   latest_scheduler_heartbeat = None
   scheduler_status = 'unhealthy'
   metadatabase_status = 'healthy'
    ...  # here update the statuses
   payload = {
       'metadatabase': {'status': metadatabase_status},
       'scheduler': {
           'status': scheduler_status,
           'latest_scheduler_heartbeat': latest_scheduler_heartbeat,
       }
   }
   return health_schema.dump(payload)
   ```
   What do you think about this approach?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to