apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
35.21k stars 13.76k forks source link

Add owner to taskinstance #40429

Open wornjs opened 3 days ago

wornjs commented 3 days ago

Description add task owner information to taskinstance

Use case/motivation I am sending an alarm to Slack using the airflow callback(on_success_callback, on_failure_callback) function.

I create an alarm message using the information of the task instance, and it would be better if the task owner information is included here.

Closes: https://github.com/apache/airflow/issues/40366

boring-cyborg[bot] commented 3 days ago

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) Here are some useful points:

wornjs commented 1 day ago

Could you add a test that tries to access this parameter on runtime?

@hussein-awala This is a very minor change, so it would be better to use the existing tests rather than creating a new one. I have added the task owner check logic to the test_refresh_from_db test.

jscheffl commented 1 day ago

I am worried a bit, the task instance table is a very huge table that potentially have millions of rows. Do we need to persist the field into the table or could we also load it from the Python object as task instance?

Note, the extension solely will not work, if really it is accepted to extend the data model, a DB migration is needed to be added.

wornjs commented 1 day ago

I am worried a bit, the task instance table is a very huge table that potentially have millions of rows. Do we need to persist the field into the table or could we also load it from the Python object as task instance?

Note, the extension solely will not work, if really it is accepted to extend the data model, a DB migration is needed to be added.

@jscheffl you means migrations/versions/xxx.py? I didn't know that, but thank you for letting me know. i add migration py how are revision and down, revision determined? They seem to be commit IDs, but the actual commits do not exist on the main branch.

potiuk commented 1 day ago

I am worried a bit, the task instance table is a very huge table that potentially have millions of rows. Do we need to persist the field into the table or could we also load it from the Python object as task instance? Note, the extension solely will not work, if really it is accepted to extend the data model, a DB migration is needed to be added.

@jscheffl you means migrations/versions/xxx.py? I didn't know that, but thank you for letting me know. i add migration py how are revision and down, revision determined? They seem to be commit IDs, but the actual commits do not exist on the main branch.

You should use alembic to generate those -those are not commits. See https://github.com/apache/airflow/blob/main/contributing-docs/13_metadata_database_updates.rst as starting point.

And I absolutely share @jscheffl worries. TaskInstance is a huge table, it can have miliions and millions of rows and it is the crucial part of the process. Modifying the DB structure and making our database less normalized is not a decision that should be taken lightly.

Have you run any performance tests on millons of rows @wornjs ? Do you know what impact it will have on the database size and memory used to store the extra data? Have you tested it on mysql and Postgres and sqlite with those millions of rows?

If the answer to any of the questions above is "no" - that change is absolutely not ready to be merged. And in generall, if the motivation is to avoid traversing from Task Instance to get the owner information in order to send slack alert, I seriously doubt this change has a serious merit.