ferruzzi commented on code in PR #76410:
URL: https://github.com/apache/airflow/pull/76410#discussion_r4685182827


##########
airflow-core/src/airflow/api/common/airflow_health.py:
##########
@@ -250,6 +377,28 @@ def get_airflow_health() -> dict[str, Any]:
         dag_processor_status = HealthStatus.UNHEALTHY
         dag_processor_detailed_status = DetailedHealthStatus.DOWN
 
+    # Omitted entirely, not just reported unhealthy, when no configured 
executor implements a health
+    # check: a reporting mechanism nothing has opted into isn't a gap in 
coverage, and showing it as
+    # "unhealthy" on every deployment that hasn't adopted it yet would be a 
false alarm, not a signal.
+    report_executor_health = bool(_configured_executor_keys())
+    if report_executor_health:
+        try:
+            executor_jobs = get_jobs_health(EXECUTOR_JOB_TYPE)
+            executor_detailed_status = _executor_detailed_status(executor_jobs)
+            executor_status = (
+                HealthStatus.UNHEALTHY
+                if executor_detailed_status == DetailedHealthStatus.DOWN
+                else HealthStatus.HEALTHY
+            )
+            if executor_jobs and executor_jobs[0].latest_heartbeat:
+                latest_executor_heartbeat = 
executor_jobs[0].latest_heartbeat.isoformat()

Review Comment:
   Sorry for the confusion on this one.
   
   To answer your question, staleness is limited by these rules right now:
   
   - Each check writes its result when it finishes, and one starts every 
`executor_health_check_interval` (30s by default).
   - A check that hangs is recorded as UNHEALTHY by the scheduler once it has 
been running for three intervals (the stall branch in 
`_check_executor_health`), so a stuck check can't leave the last HEALTHY 
showing indefinitely.
   - If the scheduler itself stops, the row's heartbeat stops moving.  After 
`scheduler_health_check_threshold` the row no longer counts as alive, and 
`_live_executor_jobs` drops it.
   
   So, as it stands now, the `/monitor/health` endpoint can't show a result 
that is older than a few intervals without it flipping to UNHEALTHY or dropping 
out.
   
   If you still want a last-checked timestamp, we can add one.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to