1 year ago

#377983

test-img

cgallegu

Changing timezone triggers DAG's last execution again

I have an issue managing the Timezones, I know that Airflow runs with UTC Timezone, I live in Santiago/Chile and I need the Dag's to work with the local time zone.

In order to manage this I changed the timezone of my DAG like this:

timezon = "Etc/GMT" + Variable.get("timezoneVariable")
chile_tz = pendulum.timezone(timezon)

The Variable timezoneVariable is set to "+3" in order to simulate our timezone.

Then the DAG is configurated as it follows:

with DAG(
        dag_id = "DAG_1",
        default_args = default_args,
        max_active_runs = 1,
        schedule_interval = "0 14 * * 2,5", 
        start_date = datetime.datetime(2022,1,26, tzinfo=chile_tz),
        catchup = False
    ) as dag:

When I do this the schedule_interval gets hooked to the chilean timezone and not to UTC.

The problem occurs when we change timezones for the daylight saving, the idea is that I don't have to change every DAG schedule interval, I only need to change the timezoneVariable from "+3" to "+4" and we are ready (I know that we can put Chile/Continental timezone for it to change automatically but we want to have the control in order to plan when we'll do the timezone change). When I changed the variable value from "+3" to "+4" it changed the timezone in every single DAG configured this way which is correct, but I also triggered again the last execution of every single DAG

In my example case the DAG triggered normally on tuesday "2022-03-29" and friday "2022-04-01", but on Sunday "2022-04-03" we did the timezone change and it triggered a new DAG execution with run execution "2022-03-29" (same value as the friday execution).

Thanks!

I want to know how can I avoid that every DAG triggers again the next time we change timezones.

Thanks!

python

google-cloud-platform

airflow

airflow-scheduler

google-cloud-composer

0 Answers

Your Answer

Accepted video resources