Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jobs/triggerer_job_runner): add triggerer canceled log #31757

Merged

Conversation

Lee-W
Copy link
Member

@Lee-W Lee-W commented Jun 7, 2023

closes: #31720


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

@boring-cyborg boring-cyborg bot added the area:Scheduler including HA (high availability) scheduler label Jun 7, 2023
@Lee-W Lee-W force-pushed the add-a-log-message-when-a-trigger-is-canceled branch 2 times, most recently from e7ed504 to fd96e7d Compare June 7, 2023 10:09
@Lee-W Lee-W marked this pull request as ready for review June 7, 2023 10:18
@Lee-W Lee-W requested review from kaxil, ashb and XD-DENG as code owners June 7, 2023 10:18
@Lee-W Lee-W force-pushed the add-a-log-message-when-a-trigger-is-canceled branch 2 times, most recently from 92a4772 to efd4e0c Compare June 9, 2023 04:24
@eladkal eladkal added the type:bug-fix Changelog: Bug Fixes label Jun 10, 2023
@eladkal eladkal added this to the Airlfow 2.6.3 milestone Jun 10, 2023
@Lee-W Lee-W force-pushed the add-a-log-message-when-a-trigger-is-canceled branch from 69471d7 to f98d0fe Compare June 12, 2023 06:44
@Lee-W Lee-W force-pushed the add-a-log-message-when-a-trigger-is-canceled branch from f98d0fe to 9e65ed4 Compare June 13, 2023 03:17
@Lee-W Lee-W marked this pull request as draft June 13, 2023 11:00
@Lee-W
Copy link
Member Author

Lee-W commented Jun 13, 2023

@dstandish I tried to dig into the code a bit and found out the error message mentioned in #30853 (comment) is from check_trigger_timeouts. Thus, I tried to add a similar timeout check here. I've not yet had time to test it today but would like to see what you think about it. Thanks!

@Lee-W Lee-W force-pushed the add-a-log-message-when-a-trigger-is-canceled branch 3 times, most recently from 1679327 to d5580b6 Compare June 14, 2023 11:39
@Lee-W Lee-W marked this pull request as ready for review June 14, 2023 11:46
@Lee-W Lee-W force-pushed the add-a-log-message-when-a-trigger-is-canceled branch from 0fe0cd4 to c38635b Compare June 16, 2023 03:17
…o error when encountering asyncio.CancelledError
trigger_timeout = trigger.task_instance.trigger_timeout
if trigger_timeout:
if not trigger_timeout.tzinfo:
trigger_timeout = trigger_timeout.replace(tzinfo=timezone.utc)
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why the the tzinfo line is necessary. it seems that it should already be UTC. are you just being defensive or did you encounter an issue?

Copy link
Member Author

@Lee-W Lee-W Jun 16, 2023

Choose a reason for hiding this comment

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

Yep, I encountered the timezone issue after I change the fallback here to 1.0 for testing.

if timeout := trigger.task_instance.trigger_timeout:
timeout = timeout.replace(tzinfo=timezone.utc) if not timeout.tzinfo else timeout
if timeout < timezone.utcnow():
self.log.error("Trigger cancelled due to timeout")
Copy link
Contributor

Choose a reason for hiding this comment

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

In the timeout case, does it log the error twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it logs the timeout error and the original asyncio.CancelledError message

Copy link
Contributor

@syedahsn syedahsn left a comment

Choose a reason for hiding this comment

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

Nice work!

@dstandish dstandish merged commit a60429e into apache:main Jun 16, 2023
@dstandish dstandish deleted the add-a-log-message-when-a-trigger-is-canceled branch June 16, 2023 08:31
ephraimbuddy pushed a commit that referenced this pull request Jul 6, 2023
Emit log message when trigger is cancelled

Co-authored-by: Daniel Standish <[email protected]>
Co-authored-by: Jed Cunningham <[email protected]>
(cherry picked from commit a60429e)
pankajkoti added a commit to astronomer/airflow that referenced this pull request Aug 29, 2023
We tried to address apache#31720 in PR apache#31757. The issue talked about
adding a trigger cancelled log when trigger timesout, but we also
added a generic Trigger canceled log. This log appears even in
successful runs of the triggers when they finish. This is confusing
some users as the log level is Error and there are sometimes quite
a few log lines saying "Trigger cancelled; err=" with giving no
clue as to what is happening.
So, I am removing this generic error log line and we can add specific
cancel scenarios with detailed reasons when we implement those.
potiuk pushed a commit that referenced this pull request Aug 29, 2023
We tried to address #31720 in PR #31757. The issue talked about
adding a trigger cancelled log when trigger timesout, but we also
added a generic Trigger canceled log. This log appears even in
successful runs of the triggers when they finish. This is confusing
some users as the log level is Error and there are sometimes quite
a few log lines saying "Trigger cancelled; err=" with giving no
clue as to what is happening.
So, I am removing this generic error log line and we can add specific
cancel scenarios with detailed reasons when we implement those.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Scheduler including HA (high availability) scheduler type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a log message when a trigger is canceled for timeout
9 participants