From 37c8a28f4b944295c2f167cd4362be32f238d8d1 Mon Sep 17 00:00:00 2001 From: David Mateo Date: Fri, 14 Apr 2023 12:54:17 +0200 Subject: [PATCH 1/4] Optional use of -n scheduler_runs in scheduler service --- defaults/main/main.yml | 2 +- templates/airflow-environment-file.j2 | 2 ++ templates/airflow-profile.d-file.j2 | 2 ++ templates/airflow-scheduler.service.j2 | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/defaults/main/main.yml b/defaults/main/main.yml index 334f543..9a70893 100644 --- a/defaults/main/main.yml +++ b/defaults/main/main.yml @@ -159,7 +159,7 @@ airflow_admin_users: # email: # Service options -airflow_scheduler_runs: 1000 +# airflow_scheduler_runs: 1000 airflow_private_tmp: false airflow_services: diff --git a/templates/airflow-environment-file.j2 b/templates/airflow-environment-file.j2 index 4ac9265..c98f4cb 100644 --- a/templates/airflow-environment-file.j2 +++ b/templates/airflow-environment-file.j2 @@ -19,7 +19,9 @@ # # required setting, 0 sets it to unlimited. Scheduler will get restart after every X runs +{% if airflow_scheduler_runs is defined %} SCHEDULER_RUNS={{ airflow_scheduler_runs }} +{% endif %} AIRFLOW_HOME={{ airflow_app_home }} AIRFLOW_CONFIG={{ airflow_conf_path }}/airflow.cfg diff --git a/templates/airflow-profile.d-file.j2 b/templates/airflow-profile.d-file.j2 index bf1bb04..777d7d7 100644 --- a/templates/airflow-profile.d-file.j2 +++ b/templates/airflow-profile.d-file.j2 @@ -18,7 +18,9 @@ # AIRFLOW_HOME= # # required setting, 0 sets it to unlimited. Scheduler will get restart after every X runs +{% if airflow_scheduler_runs is defined %} export SCHEDULER_RUNS={{ airflow_scheduler_runs }} +{% endif %} if [ -d "{{ airflow_app_home }}/bin" ] ; then export PATH="{{ airflow_app_home }}/bin:$PATH" diff --git a/templates/airflow-scheduler.service.j2 b/templates/airflow-scheduler.service.j2 index bbdd1ff..4f3710c 100644 --- a/templates/airflow-scheduler.service.j2 +++ b/templates/airflow-scheduler.service.j2 @@ -22,7 +22,7 @@ EnvironmentFile={{ airflow_environment_file_folder }}/airflow User={{ airflow_user }} Group={{ airflow_group }} Type=simple -ExecStart={{ airflow_executable }} scheduler -n ${SCHEDULER_RUNS} --pid {{ airflow_pidfile_folder }}-scheduler/scheduler.pid +ExecStart={{ airflow_executable }} scheduler {% if airflow_scheduler_runs is defined %}-n ${SCHEDULER_RUNS} {% endif %}--pid {{ airflow_pidfile_folder }}-scheduler/scheduler.pid KillSignal=SIGINT Restart=always RestartSec=5s From a2b7bb1d0f9140fe320896cbd5051cf292a02648 Mon Sep 17 00:00:00 2001 From: David Mateo Date: Fri, 14 Apr 2023 12:55:38 +0200 Subject: [PATCH 2/4] Moved from install.yml the copy env file task to service.yml tasks --- tasks/install.yml | 17 ----------------- tasks/service.yml | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tasks/install.yml b/tasks/install.yml index 58a33d2..cf7aff1 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -150,20 +150,3 @@ - restart airflow-scheduler - restart airflow-worker - restart airflow-flower - -- name: Airflow | Copy Environment File - template: - src: airflow-environment-file.j2 - dest: "{{ airflow_environment_file_folder }}/airflow" - mode: 0644 - owner: "{{ airflow_user }}" - group: "{{ airflow_group }}" - -- name: Airflow | Copy Daemon scripts - template: - src: "{{ item.value.path }}" - dest: "/lib/systemd/system/{{ item.value.service_name }}.service" - mode: 0644 - notify: restart {{ item.value.service_name }} - with_dict: "{{ airflow_services }}" - when: item.value.enabled diff --git a/tasks/service.yml b/tasks/service.yml index cda9426..84ef5ae 100644 --- a/tasks/service.yml +++ b/tasks/service.yml @@ -1,5 +1,22 @@ --- +- name: Airflow | Copy Environment File + template: + src: airflow-environment-file.j2 + dest: "{{ airflow_environment_file_folder }}/airflow" + mode: 0644 + owner: "{{ airflow_user }}" + group: "{{ airflow_group }}" + +- name: Airflow | Copy Daemon scripts + template: + src: "{{ item.value.path }}" + dest: "/lib/systemd/system/{{ item.value.service_name }}.service" + mode: 0644 + notify: restart {{ item.value.service_name }} + with_dict: "{{ airflow_services }}" + when: item.value.enabled + - name: Airflow | Configuring service systemd: name: "{{ item.value.service_name }}" From a8ec3918f12a74fcf7b6e4627d856349581947be Mon Sep 17 00:00:00 2001 From: David Mateo Date: Fri, 14 Apr 2023 13:37:44 +0200 Subject: [PATCH 3/4] Optional use of -n scheduler_runs in scheduler service --- defaults/main/main.yml | 2 +- templates/airflow-environment-file.j2 | 2 ++ templates/airflow-profile.d-file.j2 | 2 ++ templates/airflow-scheduler.service.j2 | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/defaults/main/main.yml b/defaults/main/main.yml index 334f543..9a70893 100644 --- a/defaults/main/main.yml +++ b/defaults/main/main.yml @@ -159,7 +159,7 @@ airflow_admin_users: # email: # Service options -airflow_scheduler_runs: 1000 +# airflow_scheduler_runs: 1000 airflow_private_tmp: false airflow_services: diff --git a/templates/airflow-environment-file.j2 b/templates/airflow-environment-file.j2 index 4ac9265..c98f4cb 100644 --- a/templates/airflow-environment-file.j2 +++ b/templates/airflow-environment-file.j2 @@ -19,7 +19,9 @@ # # required setting, 0 sets it to unlimited. Scheduler will get restart after every X runs +{% if airflow_scheduler_runs is defined %} SCHEDULER_RUNS={{ airflow_scheduler_runs }} +{% endif %} AIRFLOW_HOME={{ airflow_app_home }} AIRFLOW_CONFIG={{ airflow_conf_path }}/airflow.cfg diff --git a/templates/airflow-profile.d-file.j2 b/templates/airflow-profile.d-file.j2 index bf1bb04..777d7d7 100644 --- a/templates/airflow-profile.d-file.j2 +++ b/templates/airflow-profile.d-file.j2 @@ -18,7 +18,9 @@ # AIRFLOW_HOME= # # required setting, 0 sets it to unlimited. Scheduler will get restart after every X runs +{% if airflow_scheduler_runs is defined %} export SCHEDULER_RUNS={{ airflow_scheduler_runs }} +{% endif %} if [ -d "{{ airflow_app_home }}/bin" ] ; then export PATH="{{ airflow_app_home }}/bin:$PATH" diff --git a/templates/airflow-scheduler.service.j2 b/templates/airflow-scheduler.service.j2 index bbdd1ff..4f3710c 100644 --- a/templates/airflow-scheduler.service.j2 +++ b/templates/airflow-scheduler.service.j2 @@ -22,7 +22,7 @@ EnvironmentFile={{ airflow_environment_file_folder }}/airflow User={{ airflow_user }} Group={{ airflow_group }} Type=simple -ExecStart={{ airflow_executable }} scheduler -n ${SCHEDULER_RUNS} --pid {{ airflow_pidfile_folder }}-scheduler/scheduler.pid +ExecStart={{ airflow_executable }} scheduler {% if airflow_scheduler_runs is defined %}-n ${SCHEDULER_RUNS} {% endif %}--pid {{ airflow_pidfile_folder }}-scheduler/scheduler.pid KillSignal=SIGINT Restart=always RestartSec=5s From f618a785759adbc7586ba8309e3d3acbcdd79fea Mon Sep 17 00:00:00 2001 From: David Mateo Date: Fri, 14 Apr 2023 14:01:33 +0200 Subject: [PATCH 4/4] Bump Changelog --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd64590..772c5eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog). ## [Unreleased](https://github.com/idealista/airflow-role/tree/develop) + +## [2.0.7](https://github.com/idealista/airflow-role/tree/2.0.7) + +[Full Changelog](https://github.com/idealista/airflow-role/compare/2.0.6...2.0.7) + +### Fixed +- #114 The "-n" option might not be needed + +## [2.0.6](https://github.com/idealista/airflow-role/tree/2.0.6) + +[Full Changelog](https://github.com/idealista/airflow-role/compare/2.0.5...2.0.6) + ### Fixed - :hammer_and_wrench: Allow intalling only some services - :hammer_and_wrench: Updating travis environment