Skip to content

Commit e29caea

Browse files
authored
fix: Switch sensors to poke mode for accurate status duration (GoogleCloudPlatform#1131)
This change improves the observability and efficiency of task sensors under folder `dags/tpu_observability` by switching their operational mode from "reschedule" to "poke" to: 1. Enhanced Troubleshooting Visibility: In poke mode, the sensor remains active in a single session. This allows the Airflow UI (Gantt Chart & Task Duration views) to show the exact, continuous time spent waiting for TPU resources. 2. High-Value Resource Prioritization (TPU/Cluster vs. Worker): TPU/Cluster resources are far more precious and limited than Airflow worker slots. Using poke ensures zero-latency task handoff. Holding a worker slot during the poke interval has a negligible impact on cluster capacity unless the system is running a massive number of highly parallelized DAGs.
1 parent 9bf85a9 commit e29caea

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

dags/tpu_observability/utils/jobset_util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def list_pod_names(node_pool: node_pool_info, namespace: str) -> list[str]:
458458
return pod_list
459459

460460

461-
@task.sensor(poke_interval=30, timeout=900, mode="reschedule")
461+
@task.sensor(poke_interval=30, timeout=900, mode="poke")
462462
def wait_for_jobset_started(
463463
node_pool: node_pool_info,
464464
pod_name_list: str,
@@ -525,7 +525,7 @@ def wait_for_jobset_started(
525525
return all(p > threshold_value for p in last_n_data_points)
526526

527527

528-
@task.sensor(poke_interval=60, timeout=3600, mode="reschedule")
528+
@task.sensor(poke_interval=60, timeout=3600, mode="poke")
529529
def wait_for_jobset_ttr_to_be_found(node_pool: node_pool_info) -> bool:
530530
"""
531531
Polls the jobset time_between_interruptions metric.
@@ -559,7 +559,7 @@ def wait_for_jobset_ttr_to_be_found(node_pool: node_pool_info) -> bool:
559559
return len(time_series) > 0
560560

561561

562-
@task.sensor(poke_interval=30, timeout=600, mode="reschedule")
562+
@task.sensor(poke_interval=30, timeout=600, mode="poke")
563563
def wait_for_jobset_status_occurrence(
564564
replica_type: str, job_name: str, node_pool: node_pool_info
565565
):
@@ -581,7 +581,7 @@ def wait_for_jobset_status_occurrence(
581581
return ready_replicas > 0
582582

583583

584-
@task.sensor(poke_interval=30, timeout=600, mode="reschedule")
584+
@task.sensor(poke_interval=30, timeout=600, mode="poke")
585585
def wait_for_all_pods_running(num_pods: int, node_pool: node_pool_info):
586586
num_running = len(get_running_pods(node_pool=node_pool, namespace="default"))
587587
return num_running == num_pods

dags/tpu_observability/utils/node_pool_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def _query_status_metric(node_pool: Info) -> Status:
413413
return Status.from_str(latest_status)
414414

415415

416-
@task.sensor(poke_interval=60, timeout=600, mode="reschedule")
416+
@task.sensor(poke_interval=60, timeout=600, mode="poke")
417417
def wait_for_status(
418418
node_pool: Info,
419419
status: Status,
@@ -465,7 +465,7 @@ def rollback(node_pool: Info) -> None:
465465
subprocess.run_exec(command)
466466

467467

468-
@task.sensor(poke_interval=30, timeout=1200, mode="reschedule")
468+
@task.sensor(poke_interval=30, timeout=1200, mode="poke")
469469
def wait_for_availability(
470470
node_pool: Info,
471471
availability: bool,
@@ -541,7 +541,7 @@ def wait_for_availability(
541541
return availability == state
542542

543543

544-
@task.sensor(poke_interval=30, timeout=3600, mode="reschedule")
544+
@task.sensor(poke_interval=30, timeout=3600, mode="poke")
545545
def wait_for_ttr(
546546
node_pool: Info,
547547
operation_start_time: TimeUtil,

0 commit comments

Comments
 (0)