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

Fix double logging with some task logging handler #27591

Merged

Conversation

ashb
Copy link
Member

@ashb ashb commented Nov 10, 2022

A previous change to fix disappearing log messages turned on propagation for the airflow.task logger, and disabled it again after set_context() was called, but only if that function returned a special sentinel value.

For the "core" task log handlers we returned them, but some providers weren't "correctly" subclassing and weren't returning this sentinel value.

The fix here is to change the logic from disable only on special value to disable by default and maintain propagation on special value; this means that if a handler doesn't return the value from super() (or if they don't even subclass the default handler) propagation will still be disabled by default.

Fixes #27345

@ashb ashb added type:bug-fix Changelog: Bug Fixes priority:high High priority bug that should be patched quickly but does not require immediate new release labels Nov 10, 2022
@ashb ashb added this to the Airflow 2.4.3 milestone Nov 10, 2022
@ashb ashb requested a review from eladkal as a code owner November 10, 2022 13:52
@ashb ashb requested a review from potiuk November 10, 2022 14:59


def __getattr__(name):
if name in ("DISABLE_PROPOGATE", "DISABLE_PROPAGATE"):
Copy link
Member

Choose a reason for hiding this comment

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

:D

Copy link
Member Author

Choose a reason for hiding this comment

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

We all knew I couldn't spell right?

(The switch to an Enum was for typing reasons, no easy way of saying "returns none or this specific object type")

Copy link
Member

Choose a reason for hiding this comment

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

Looking forward to the depreciation warning hahahaha :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Luckily in this case I don't think we need one: it was only for a single point release, and it didn't really work in practice

😅

Copy link
Member

Choose a reason for hiding this comment

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

But I want to see you suffer 😆 You need to learn from those mistakes 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

NEVER!

@ashb ashb removed provider:amazon-aws AWS/Amazon - related issues area:providers labels Nov 10, 2022
@potiuk
Copy link
Member

potiuk commented Nov 10, 2022

Nice

@ashb
Copy link
Member Author

ashb commented Nov 10, 2022

It appears my PR skills have attrophied to the point where I'm just making silly mistakes :D

A previous change to fix disappearing log messages turned on propagation
for the `airflow.task` logger, and disabled it again after
`set_context()` was called, but only if that function returned a special
sentinel value.

For the "core" task log handlers we returned them, but some providers
weren't "correctly" subclassing and weren't returning this sentinel
value.

The fix here is to change the logic from disable only on speical value
to disable by default and maintain propagation on special value; this
means that if a handler doesn't return the value from `super()` (or if
they don't even subclass the default handler) propagation will still be
disabled by default.
@ashb ashb force-pushed the prevent-double-logging-some-task-handlers branch from 4820ec6 to d7f50d8 Compare November 10, 2022 17:32
@ashb ashb merged commit 933fefc into apache:main Nov 10, 2022
@ashb ashb deleted the prevent-double-logging-some-task-handlers branch November 10, 2022 17:58
ephraimbuddy pushed a commit that referenced this pull request Nov 10, 2022
A previous change to fix disappearing log messages turned on propagation
for the `airflow.task` logger, and disabled it again after
`set_context()` was called, but only if that function returned a special
sentinel value.

For the "core" task log handlers we returned them, but some providers
weren't "correctly" subclassing and weren't returning this sentinel
value.

The fix here is to change the logic from disable only on special value
to disable by default and maintain propagation on special value; this
means that if a handler doesn't return the value from `super()` (or if
they don't even subclass the default handler) propagation will still be
disabled by default.

(cherry picked from commit 933fefc)
ephraimbuddy pushed a commit that referenced this pull request Nov 10, 2022
A previous change to fix disappearing log messages turned on propagation
for the `airflow.task` logger, and disabled it again after
`set_context()` was called, but only if that function returned a special
sentinel value.

For the "core" task log handlers we returned them, but some providers
weren't "correctly" subclassing and weren't returning this sentinel
value.

The fix here is to change the logic from disable only on special value
to disable by default and maintain propagation on special value; this
means that if a handler doesn't return the value from `super()` (or if
they don't even subclass the default handler) propagation will still be
disabled by default.

(cherry picked from commit 933fefc)
Adityamalik123 pushed a commit to Adityamalik123/airflow that referenced this pull request Nov 12, 2022
A previous change to fix disappearing log messages turned on propagation
for the `airflow.task` logger, and disabled it again after
`set_context()` was called, but only if that function returned a special
sentinel value.

For the "core" task log handlers we returned them, but some providers
weren't "correctly" subclassing and weren't returning this sentinel
value.

The fix here is to change the logic from disable only on special value
to disable by default and maintain propagation on special value; this
means that if a handler doesn't return the value from `super()` (or if
they don't even subclass the default handler) propagation will still be
disabled by default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:logging priority:high High priority bug that should be patched quickly but does not require immediate new release type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate log lines in CloudWatch after upgrade to 2.4.2
5 participants