You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bb...@apache.org on 2022/03/10 15:51:54 UTC

[airflow] branch scheduler-autorefresh-pause created (now c4fc2a4)

This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a change to branch scheduler-autorefresh-pause
in repository https://gitbox.apache.org/repos/asf/airflow.git.


      at c4fc2a4  pause autorefresh if scheduler isn't running

This branch includes the following new commits:

     new c4fc2a4  pause autorefresh if scheduler isn't running

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[airflow] 01/01: pause autorefresh if scheduler isn't running

Posted by bb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a commit to branch scheduler-autorefresh-pause
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit c4fc2a4a84921bbb4a045ff01efabdb4a9edd294
Author: Brent Bovenzi <br...@gmail.com>
AuthorDate: Thu Mar 10 10:40:18 2022 -0500

    pause autorefresh if scheduler isn't running
---
 airflow/www/static/js/graph.js            |  3 ++-
 airflow/www/static/js/tree/useTreeData.js | 10 +++++++++-
 airflow/www/templates/airflow/main.html   |  7 +++++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/airflow/www/static/js/graph.js b/airflow/www/static/js/graph.js
index 3cb0fbe..1ba99a8 100644
--- a/airflow/www/static/js/graph.js
+++ b/airflow/www/static/js/graph.js
@@ -35,6 +35,7 @@ const executionDate = getMetaValue('execution_date');
 const dagRunId = getMetaValue('dag_run_id');
 const arrange = getMetaValue('arrange');
 const taskInstancesUrl = getMetaValue('task_instances_url');
+const isSchedulerRunning = getMetaValue('is_scheduler_running');
 
 // This maps the actual taskId to the current graph node id that contains the task
 // (because tasks may be grouped into a group node)
@@ -450,7 +451,7 @@ $('#auto_refresh').change(() => {
 function initRefresh() {
   const isDisabled = localStorage.getItem('disableAutoRefresh');
   const isFinal = checkRunState();
-  $('#auto_refresh').prop('checked', !(isDisabled || isFinal));
+  $('#auto_refresh').prop('checked', !(isDisabled || isFinal) && isSchedulerRunning === 'True');
   startOrStopRefresh();
   d3.select('#refresh_button').on('click', () => handleRefresh());
 }
diff --git a/airflow/www/static/js/tree/useTreeData.js b/airflow/www/static/js/tree/useTreeData.js
index e26a9c9..da9b4c6 100644
--- a/airflow/www/static/js/tree/useTreeData.js
+++ b/airflow/www/static/js/tree/useTreeData.js
@@ -32,6 +32,7 @@ const numRuns = getMetaValue('num_runs');
 const urlRoot = getMetaValue('root');
 const isPaused = getMetaValue('is_paused');
 const baseDate = getMetaValue('base_date');
+const isSchedulerRunning = getMetaValue('is_scheduler_running');
 
 const autoRefreshKey = 'disabledAutoRefresh';
 
@@ -55,7 +56,14 @@ const formatData = (data) => {
 const useTreeData = () => {
   const initialData = formatData(treeData);
 
-  const defaultIsOpen = isPaused !== 'True' && !JSON.parse(localStorage.getItem(autoRefreshKey)) && areActiveRuns(initialData.dagRuns);
+  const isRefreshDisabled = JSON.parse(localStorage.getItem(autoRefreshKey));
+  const defaultIsOpen = (
+    isPaused !== 'True'
+    && !isRefreshDisabled
+    && areActiveRuns(initialData.dagRuns)
+    && isSchedulerRunning === 'True'
+  );
+
   const { isOpen: isRefreshOn, onToggle, onClose } = useDisclosure({ defaultIsOpen });
 
   const onToggleRefresh = () => {
diff --git a/airflow/www/templates/airflow/main.html b/airflow/www/templates/airflow/main.html
index d57f5f0..19cc717 100644
--- a/airflow/www/templates/airflow/main.html
+++ b/airflow/www/templates/airflow/main.html
@@ -28,6 +28,13 @@
   {% endif%}
 {% endblock %}
 
+{% block head_meta %}
+  {{ super() }}
+  {% if scheduler_job is defined and scheduler_job.is_alive() %}
+    <meta name="is_scheduler_running" content="True">
+  {% endif %}
+{% endblock %}
+
 {% block head_css %}
   {{ super() }}