You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "sachinp97 (via GitHub)" <gi...@apache.org> on 2024/03/15 16:47:54 UTC
[PR] Fix in decorators and simple test case for #36057 [airflow]
sachinp97 opened a new pull request, #38192:
URL: https://github.com/apache/airflow/pull/38192
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
The changes include fix for issue#36057 to add dag-id to the audit logs whenever a dagrun is deleted.
A unit test case is included to test if the changes are working or not.
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators and simple test case for #36057 [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2000055832
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]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks) 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](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) 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](https://www.apache.org/foundation/policies/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]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- 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
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "vchiapaikeo (via GitHub)" <gi...@apache.org>.
vchiapaikeo commented on code in PR #38192:
URL: https://github.com/apache/airflow/pull/38192#discussion_r1534939714
##########
airflow/www/decorators.py:
##########
@@ -125,6 +126,9 @@ def wrapper(*args, **kwargs):
extra_fields = {**extra_fields, **masked_json}
params = {**request.values, **request.view_args}
+
+ dag_id = params.get("dag_id") or session.scalar(select(DagRun.dag_id)
+ .where(DagRun.id == params.get("pk")))
Review Comment:
What if we did something like this instead to avoid the issue mentioned earlier?
```suggestion
dag_id = params.get("dag_id") or (session.scalar(select(DagRun.dag_id)
.where(DagRun.id == params.get("pk"))) if event_name == "dagrun.delete" else None)
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2246614301
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.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2010693001
Do we use `AirflowModelView.delete` anywhere else? Or will `pk` always be a DagRun.id?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "vchiapaikeo (via GitHub)" <gi...@apache.org>.
vchiapaikeo commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2014159624
> Do we use AirflowModelView.delete anywhere else? Or will pk always be a DagRun.id?
Yea, I think this is problematic because `AirflowModelView.delete` is used in several other places. For example, when I try to delete a TaskInstance, I am hit w/ this exception:
<img width="1087" alt="image" src="https://github.com/apache/airflow/assets/9200263/1c9b9fda-11b4-4949-8746-1460ded85db9">
<img width="973" alt="image" src="https://github.com/apache/airflow/assets/9200263/18001ca4-4a41-4f3a-96f9-0438cf15f460">
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "sachinp97 (via GitHub)" <gi...@apache.org>.
sachinp97 commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2014271206
> > Do we use AirflowModelView.delete anywhere else? Or will pk always be a DagRun.id?
>
> Yea, I think this is problematic because `AirflowModelView.delete` is used in several other places. For example, when I try to delete a TaskInstance, I am hit w/ this exception:
>
> <img alt="image" width="1087" src="https://private-user-images.githubusercontent.com/9200263/315853372-1c9b9fda-11b4-4949-8746-1460ded85db9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTEwNzcyMzMsIm5iZiI6MTcxMTA3NjkzMywicGF0aCI6Ii85MjAwMjYzLzMxNTg1MzM3Mi0xYzliOWZkYS0xMWI0LTQ5NDktODc0Ni0xNDYwZGVkODVkYjkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDMyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDAzMjJUMDMwODUzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTY0NjZlOTRlMTUzMTEzNjViYzVhNDM5OWFhMzc4YjM3NjgzZWEwNTA1ODExYzMzNjk4ODQzNmFiOTFmNmJhYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.4dHlyYe5wCc4yiawm7kRHbTLuG3-FS0_s30GJosahug"> <img alt="image" width="973" src="https://private-user-images.githubusercontent.com/9200263/315853452-18001ca4-4a41-4f3a-96f9-0438cf15f460.
png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTEwNzcyMzMsIm5iZiI6MTcxMTA3NjkzMywicGF0aCI6Ii85MjAwMjYzLzMxNTg1MzQ1Mi0xODAwMWNhNC00YTQxLTRmM2EtOTZmOS0wNDM4Y2YxNWY0NjAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDMyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDAzMjJUMDMwODUzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTQ5YzU2NzBjOGZkOTI3NzVhN2YzZTJlOTBmZTBkMTg2ZTg4ODg0ZTg0ZGVmM2Q2NDQyNWZlMDNjYWFlOWQ2MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.brxFjwbwqxUFkJRWN-ZtghyRz9ij_9mMOWIxVQs2OPk">
Good catch @bbovenzi and Thanks @vchiapaikeo for suggested solution.
Although this works, it makes decorators bit clumsy with checks for specific use-cases.
What do you think?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2088034788
@sachinp97 are you still working on this PR?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #38192: Fix in decorators to log dag-id during delete dag-run action #36057
URL: https://github.com/apache/airflow/pull/38192
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators and simple test case for #36057 [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #38192:
URL: https://github.com/apache/airflow/pull/38192#discussion_r1527149049
##########
airflow/www/decorators.py:
##########
@@ -106,6 +107,8 @@ def wrapper(*args, **kwargs):
extra_fields = _mask_connection_fields(extra_fields)
params = {**request.values, **request.view_args}
+ dag_id = params.get("dag_id") if params.get("dag_id") else session.scalar(select(DagRun.dag_id)
+ .where(DagRun.id == params.get("pk")))
Review Comment:
```suggestion
dag_id = params.get("dag_id") or session.scalar(
select(DagRun.dag_id).where(DagRun.id == params.get("pk"))
)
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "vchiapaikeo (via GitHub)" <gi...@apache.org>.
vchiapaikeo commented on code in PR #38192:
URL: https://github.com/apache/airflow/pull/38192#discussion_r1534940649
##########
airflow/www/decorators.py:
##########
@@ -125,6 +126,9 @@ def wrapper(*args, **kwargs):
extra_fields = {**extra_fields, **masked_json}
params = {**request.values, **request.view_args}
+
+ dag_id = params.get("dag_id") or session.scalar(select(DagRun.dag_id)
+ .where(DagRun.id == params.get("pk")))
Review Comment:
This allows me to still delete taskinstances fine and also dagruns.
<img width="762" alt="image" src="https://github.com/apache/airflow/assets/9200263/a5292696-d2f3-4f47-b604-bb93ad35e888">
However, if I tried to delete multiple, this would still not work -
<img width="948" alt="image" src="https://github.com/apache/airflow/assets/9200263/ff9048dc-e80b-4dfc-9ca8-7938b132bd1e">
<img width="945" alt="image" src="https://github.com/apache/airflow/assets/9200263/14de6dd2-762f-495c-9abe-4984648a1242">
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators to log dag-id during delete dag-run action #36057 [airflow]
Posted by "sachinp97 (via GitHub)" <gi...@apache.org>.
sachinp97 commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2010676453
Updated the description to indicate the intent
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix in decorators and simple test case for #36057 [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38192:
URL: https://github.com/apache/airflow/pull/38192#issuecomment-2008689814
Could you please add a little more description in the commit what problem it fixes - just reference to an issue is not enough - when we merge the commit, it's good to see what problem it solves from just commit message. The issue might be removed or disappear but the commit message will remain (and you will see what it is about without having to look elsewhere)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org