Ensure `on_task_instance_running` listener can get at task (#21157)
Ensure `on_task_instance_running` listener can get at task (#21157)

When we added TaskListener API. It's contract promises to pass TaskInstance
object to listener plugin. However, what happens is not 100% true
- the object being passed is one that maps to current SQLAlchemy session.

`check_and_change_state_before_execution` operates on detached TaskInstance
object, then merges it to current session. Since there is no attached object in
the SQLAlchemy identity map, SQLAlchemy creates it, and it's this object that's
being passed to the SQLAlchemy event listeners.

The problem with that is that when creating new SQLAlchemy object, SQLAlchemy
takes care about setting only database-mapped fields. The ones that are purely
on the python side, like task aren't being set on the new object.

This manually sets task on the new SQLAlchemy object, so that
`on_task_instance_running` receives a TaskInstance with `task` field set.

Signed-off-by: Maciej Obuchowski <909b47c70dda2b53bc9d2d0e7e30fed29eea65e4@gmail.com>
Acehaidrey/incubator-airflow,apache/airflow,apache/airflow,Acehaidrey/incubator-airflow,nathanielvarona/airflow,lyft/incubator-airflow,Acehaidrey/incubator-airflow,Acehaidrey/incubator-airflow,cfei18/incubator-airflow,bolkedebruin/airflow,apache/airflow,lyft/incubator-airflow,nathanielvarona/airflow,bolkedebruin/airflow,apache/airflow,nathanielvarona/airflow,danielvdende/incubator-airflow,bolkedebruin/airflow,Acehaidrey/incubator-airflow,bolkedebruin/airflow,danielvdende/incubator-airflow,nathanielvarona/airflow,cfei18/incubator-airflow,cfei18/incubator-airflow,danielvdende/incubator-airflow,cfei18/incubator-airflow,cfei18/incubator-airflow,nathanielvarona/airflow,lyft/incubator-airflow,nathanielvarona/airflow,Acehaidrey/incubator-airflow,lyft/incubator-airflow,apache/airflow,apache/airflow,danielvdende/incubator-airflow,danielvdende/incubator-airflow,bolkedebruin/airflow,cfei18/incubator-airflow,danielvdende/incubator-airflow