fix(k8s-executor): add latency + status metrics around pod API calls#66806
Merged
Conversation
jscheffl
approved these changes
May 12, 2026
potiuk
approved these changes
May 12, 2026
Wrap create/delete/patch pod calls with Stats.timer for latency and Stats.incr tagged by HTTP status for outcome counts. Lets operators alert on slow control-plane calls and on 429/5xx error surges instead of inferring them from scheduler log noise. Closes: apache#66799 Signed-off-by: 1fanwang <1fannnw@gmail.com>
61f3400 to
0e30e68
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
KubernetesExecutorcallscreate_namespaced_pod,delete_namespaced_pod, andpatch_namespaced_podagainst the API server on every task lifecycle event, but emits no metrics around those calls. When a cluster's control plane is slow, throttling (HTTP 429), or returning 5xx, the only signal today is scheduler log noise — there's no way to alert on latency drift or error-rate spikes without scraping logs.Grafana Dashboard graphing these metrics from our internal fork
Fix
Wrap each of the three pod API call sites in
kubernetes_executor_utils.pywithStats.timerfor latency (kubernetes_executor.pod_creation/pod_deletion/pod_patching) and a pairedStats.incrtagged by status (pod_creation_status/pod_deletion_status/pod_patching_status). The counter is taggedstatus="200"on success and with theApiException.statusvalue on failure, so operators can chart per-status-code rates. The 404-is-fine branch indelete_podand the swallow-on-failure branches in the two patch methods still behave as before — they just emit a counter on the way out.The three new timers and three new counters are registered in
shared/observability/src/airflow_shared/observability/metrics/metrics_template.yamlso they pass the metrics-registry pre-commit hook and show up in the published metrics docs.Tests
New unit tests in
test_kubernetes_executor.pymock theStatsmodule and assert the timer + tagged counter fire on both the success path and anApiException(status=429)failure path fordelete_pod.Closes #66799