Skip to content

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="xyz@gmail.com"),
):
    BashOperator(
        task_id="task",
        bash_command="sleep 5 && exit 1",
        retries=1,
        sla=timedelta(seconds=30),
        on_success_callback=SmtpNotifier(from_email=None, to="xyz@gmail.com"),
        on_failure_callback=SmtpNotifier(from_email=None, to="xyz@gmail.com"),
        on_retry_callback=SmtpNotifier(from_email=None, to="xyz@gmail.com"),
    )

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

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

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

potiuk commented Feb 27, 2024

Should be good to go @eladkal

@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
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