Skip to content

Add owner to taskinstance#40429

Closed
wornjs wants to merge 5 commits intoapache:mainfrom
wornjs:add_owner_to_taskinstance
Closed

Add owner to taskinstance#40429
wornjs wants to merge 5 commits intoapache:mainfrom
wornjs:add_owner_to_taskinstance

Conversation

@wornjs
Copy link

@wornjs wornjs commented Jun 26, 2024

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: #40366

@wornjs wornjs requested review from XD-DENG, ashb and kaxil as code owners June 26, 2024 02:59
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 26, 2024

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:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@wornjs
Copy link
Author

wornjs commented Jun 27, 2024

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
Copy link
Contributor

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
Copy link
Author

wornjs commented Jun 28, 2024

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
Copy link
Member

potiuk commented Jun 28, 2024

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.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes as there is a doubt if that change is good at all.

@uranusjr
Copy link
Member

I don't think this is a good idea, trying to access the information on the task would be better.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Aug 26, 2024
@github-actions github-actions bot closed this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add ower to TaskInstance class

5 participants