diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 3a53887b78baa..f6c0c09fc085f 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -1875,6 +1875,13 @@ webserver: type: boolean example: ~ default: "False" + num_recent_configurations_for_trigger: + description: | + Number of recent DAG run configurations in the selector on the trigger web form. + version_added: 2.9.0 + type: integer + example: "10" + default: "5" allow_raw_html_descriptions: description: | A DAG author is able to provide any raw HTML into ``doc_md`` or params description in diff --git a/airflow/www/views.py b/airflow/www/views.py index 2f085c795bc2f..12b819c1f37d4 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -2029,6 +2029,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION): flash(f"Cannot create dagruns because the dag {dag_id} has import errors", "error") return redirect(origin) + num_recent_confs = conf.getint("webserver", "num_recent_configurations_for_trigger") recent_runs = session.execute( select(DagRun.conf, func.max(DagRun.run_id).label("run_id"), func.max(DagRun.execution_date)) .where( @@ -2038,7 +2039,7 @@ def trigger(self, dag_id: str, session: Session = NEW_SESSION): ) .group_by(DagRun.conf) .order_by(func.max(DagRun.execution_date).desc()) - .limit(5) + .limit(num_recent_confs) ) recent_confs = { run_id: json.dumps(run_conf)