Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky order of returned dag runs #24405

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions airflow/www/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,25 @@ def get_mapped_summary(parent_instance, task_instances):


def get_task_summaries(task, dag_runs: List[DagRun], session: Session) -> List[Dict[str, Any]]:
tis = session.query(
TaskInstance.dag_id,
TaskInstance.task_id,
TaskInstance.run_id,
TaskInstance.map_index,
TaskInstance.state,
TaskInstance.start_date,
TaskInstance.end_date,
TaskInstance._try_number,
).filter(
TaskInstance.dag_id == task.dag_id,
TaskInstance.run_id.in_([dag_run.run_id for dag_run in dag_runs]),
TaskInstance.task_id == task.task_id,
# Only get normal task instances or the first mapped task
TaskInstance.map_index <= 0,
tis = (
session.query(
TaskInstance.dag_id,
TaskInstance.task_id,
TaskInstance.run_id,
TaskInstance.map_index,
TaskInstance.state,
TaskInstance.start_date,
TaskInstance.end_date,
TaskInstance._try_number,
)
.filter(
TaskInstance.dag_id == task.dag_id,
TaskInstance.run_id.in_([dag_run.run_id for dag_run in dag_runs]),
TaskInstance.task_id == task.task_id,
# Only get normal task instances or the first mapped task
TaskInstance.map_index <= 0,
)
.order_by(TaskInstance.run_id.asc())
)

def _get_summary(task_instance):
Expand Down
2 changes: 0 additions & 2 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3538,7 +3538,6 @@ def grid_data(self):
'groups': task_group_to_grid(dag.task_group, dag, dag_runs, session),
'dag_runs': encoded_runs,
}

# avoid spaces to reduce payload size
return (
htmlsafe_json_dumps(data, separators=(',', ':')),
Expand Down Expand Up @@ -3579,7 +3578,6 @@ def audit_log(self, session=None):
query = query.filter(Log.event.notin_(excluded_events))

dag_audit_logs = query.all()

content = self.render_template(
'airflow/dag_audit_log.html',
dag=dag,
Expand Down