Apache Airflow version
2.11.X
If "Other Airflow 3 version" selected, which one?
No response
What happened?
Apache Airflow version
2.11.x
What happened
The task_instance_mutation_hook defined in airflow_local_settings.py is registered correctly with POLICY_PLUGIN_MANAGER (confirmed via startup logs), but the hook function is never invoked when tasks are scheduled.
What you think should happen instead?
The hook should be called for each task instance before scheduling, allowing modifications to pool and other properties.
How to reproduce
- Create
$AIRFLOW_HOME/config/airflow_local_settings.py:
def task_instance_mutation_hook(task_instance):
print(f"HOOK CALLED: task={task_instance.task_id}")
# Modify pool for manual runs
run_id = getattr(task_instance, 'run_id', '')
if run_id.startswith('manual__'):
task_instance.pool = "high_priority_pool"
print("airflow_local_settings loaded")
2.Trigger any DAG manually: airflow dags trigger <dag_id>
3.Expected: Logs show "HOOK CALLED: task=..."
Actual: Hook is never called, no log output
Additional attempts (all failed)
Plugin with @hookimpl decorator and explicit POLICY_PLUGIN_MANAGER.register()
Monkey-patching airflow.settings and airflow.models.taskinstance
All approaches show successful registration but the hook is never invoked.
Operating System
macOS/Linux
Versions of Apache Airflow Providers
N/A - core issue
Deployment
Docker-Compose
Deployment details
Docker Compose with CeleryExecutor
Anything else?
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow version
2.11.X
If "Other Airflow 3 version" selected, which one?
No response
What happened?
Apache Airflow version
2.11.x
What happened
The
task_instance_mutation_hookdefined inairflow_local_settings.pyis registered correctly withPOLICY_PLUGIN_MANAGER(confirmed via startup logs), but the hook function is never invoked when tasks are scheduled.What you think should happen instead?
The hook should be called for each task instance before scheduling, allowing modifications to
pooland other properties.How to reproduce
$AIRFLOW_HOME/config/airflow_local_settings.py:2.Trigger any DAG manually: airflow dags trigger <dag_id>
3.Expected: Logs show "HOOK CALLED: task=..."
Actual: Hook is never called, no log output
Additional attempts (all failed)
Plugin with @hookimpl decorator and explicit POLICY_PLUGIN_MANAGER.register()
Monkey-patching airflow.settings and airflow.models.taskinstance
All approaches show successful registration but the hook is never invoked.
Operating System
macOS/Linux
Versions of Apache Airflow Providers
N/A - core issue
Deployment
Docker-Compose
Deployment details
Docker Compose with CeleryExecutor
Anything else?
No response
Are you willing to submit PR?
Code of Conduct