wolvery opened a new pull request, #69762: URL: https://github.com/apache/airflow/pull/69762
Fixes #69760 This adds a final DB preflight before KubernetesExecutor creates a worker pod for an Airflow 3 ExecuteTask workload. A workload can sit in the executor queue while Kubernetes pod creation is delayed, and in HA scheduler deployments the task instance can be retried, cleared, or otherwise moved on before the pod is eventually created. The executor now verifies that the workload still matches the current queued task instance before calling run_next: - the immutable TaskInstance id still exists - the TaskInstance is still QUEUED - try_number still matches the workload - queued_by_job_id still belongs to this scheduler job If the workload is stale, it is dropped before pod creation and executor bookkeeping for that launch is cleared. Tests added: - KubernetesExecutor drops a stale ExecuteTask workload before pod creation when the DB task state has moved on Local verification: - python3 -m compileall providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py - AIRFLOW_HOME=/var/folders/_l/8htlzsws7gjg8_p6ht_hl0tc0000gp/T/opencode/airflow-test-home uv run pytest providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py::TestKubernetesExecutor::test_sync_drops_stale_execute_task_workload_before_pod_creation -q --with-db-init - AIRFLOW_HOME=/var/folders/_l/8htlzsws7gjg8_p6ht_hl0tc0000gp/T/opencode/airflow-test-home uv run pytest providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py::TestKubernetesExecutor::test_run_next_exception_requeue providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py::TestKubernetesExecutor::test_skip_pod_creation_on_create_pods_after -q - uv run ruff check providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py - uv run ruff format --check providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py -- 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]
