Hi team,

I have a question about the expected behavior of Airflow scheduler when the
schedule_interval is a cron expression and the start_date is in a timezone
with DST.

Based on the Airflow documentation
https://airflow.apache.org/timezone.html#cron-schedules, the DST change
will be ignored if schedule_interval is a cron expresion (e.g. '0 17 * *
*'). And it gives an example that the GMT offset will not change regardless
how DST changes. If I'm understanding it correctly, that means if I upload
a DAG with a schedule_interval of "0 17 * * *" and a start_date of
2019-03-15 17:00 PST(GMT-8) which is before the DST change on March 10, the
Airflow scheduler will always start the DAG on 5 pm everyday GMT-8 even
after the DST change on March 10.

However, that is not the behavior I've seen with my experimental code (see
attachments). It looks like the the Airflow is actually taking the DST into
account, since the execution time is always 17:00 locally, which is 1 hour
off on the GMT after the DST change.

Could you please confirm the behavior of Airflow scheduler in this use case?

Thank you!
Jiahao
"""
Test DAG for DST handling

2019-3-10 Sun DST changed
"""

import pendulum
from airflow import DAG
from datetime import timedelta

# 2019-3-5 Tue 17:00 PST
# 2019-3-6 Wed  1:00 GMT
_START_TIME_LOCAL = pendulum.from_timestamp(
    1572480000,
    'America/Los_Angeles')

# Set-up DAG
test_dag = DAG(
    dag_id='foo',
    start_date=_START_TIME_LOCAL,
    schedule_interval='0 17 * * 5-0',
    catchup=False
)

# Check initial schedule
execution_date = test_dag.start_date
for _ in range(7):
    next_execution_date = test_dag.following_schedule(execution_date)
    execution_date = next_execution_date
    print('Execution Date:', execution_date)

Reply via email to