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

Deprecate smtp configs in airflow settings / local_settings #37711

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

vchiapaikeo
Copy link
Contributor

@vchiapaikeo vchiapaikeo commented Feb 26, 2024

closes: #37703

This removes the usage of airflow/settings.py | airflow_local_settings.py from the templated SmtpNotifier.

Ensure emails still come through as expected:

Screenshot 2024-02-26 at 5 47 07 PM Screenshot 2024-02-26 at 5 46 59 PM Screenshot 2024-02-26 at 6 02 28 PM

Using this test dag:

import datetime

from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.smtp.notifications.smtp import SmtpNotifier
from datetime import timedelta


with DAG(
    dag_id="my_dag",
    start_date=datetime.datetime(2021, 1, 1),
    schedule="*/5 * * * *",
    catchup=False,
    max_active_tasks=1,
    max_active_runs=1,
    sla_miss_callback=SmtpNotifier(from_email=None, to="[email protected]"),
):
    BashOperator(
        task_id="task",
        bash_command="sleep 5 && exit 1",
        retries=1,
        sla=timedelta(seconds=30),
        on_success_callback=SmtpNotifier(from_email=None, to="[email protected]"),
        on_failure_callback=SmtpNotifier(from_email=None, to="[email protected]"),
        on_retry_callback=SmtpNotifier(from_email=None, to="[email protected]"),
    )

^ 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.

airflow/settings.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Taragolis Taragolis left a comment

Choose a reason for hiding this comment

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

Also would be nice to have a test with a custom values which comes thought configs.
Just in case, it could be done by a conf_vars context manager

airflow/providers/smtp/provider.yaml Outdated Show resolved Hide resolved
airflow/providers/smtp/provider.yaml Outdated Show resolved Hide resolved
@potiuk
Copy link
Member

potiuk commented Feb 26, 2024

Also I think we should release 1.6.1 NOT 1.7.0. Technically it will be a bugfix to buggy feature added it 1.6.0. Even if we yank 1.6.0, this one is still adding the same feature already added in 1.6.* (only properly).

@vchiapaikeo vchiapaikeo force-pushed the vchiapaikeo/fix-smtp-template-v2 branch from cb466f6 to 8bdc24c Compare February 26, 2024 22:44
@vchiapaikeo vchiapaikeo marked this pull request as ready for review February 26, 2024 22:50
@potiuk potiuk merged commit 5b31b63 into apache:main Feb 27, 2024
59 checks passed
@potiuk
Copy link
Member

potiuk commented Feb 27, 2024

Should be good to go @eladkal

abhishekbhakat pushed a commit to abhishekbhakat/my_airflow that referenced this pull request Mar 5, 2024
…7711)

* Deprecate smtp configs in airflow settings / local_settings

* Add header to jinja2 template

* Update tests and provider version pin
@ephraimbuddy ephraimbuddy added this to the Airflow 2.9.0 milestone Mar 6, 2024
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Mar 6, 2024
utkarsharma2 pushed a commit to astronomer/airflow that referenced this pull request Apr 22, 2024
…7711)

* Deprecate smtp configs in airflow settings / local_settings

* Add header to jinja2 template

* Update tests and provider version pin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:smtp type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decouple SMTP Provider settings from the Airflow Core
4 participants