Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Use DAG_DEFAULT_ARGS for all DAGs (#3928)
Madison Swain-Bowdenfcad99d47242
diff --git a/catalog/dags/elasticsearch_cluster/healthcheck_dag.py b/catalog/dags/elasticsearch_cluster/healthcheck_dag.pyindex 8ebecd4ed..e4455dd77 100644--- a/catalog/dags/elasticsearch_cluster/healthcheck_dag.py+++ b/catalog/dags/elasticsearch_cluster/healthcheck_dag.py@@ -25,7 +25,7 @@ from airflow.exceptions import AirflowSkipExceptionfrom airflow.providers.elasticsearch.hooks.elasticsearch import ElasticsearchPythonHookfrom elasticsearch import Elasticsearch-from common.constants import ENVIRONMENTS, PRODUCTION, Environment+from common.constants import DAG_DEFAULT_ARGS, ENVIRONMENTS, PRODUCTION, Environmentfrom common.elasticsearch import get_es_hostfrom common.sensors.utils import is_concurrent_with_anyfrom common.slack import send_alert, send_message@@ -161,6 +161,7 @@ _SHARED_DAG_ARGS = {"max_active_runs": 1,"doc_md": __doc__,"tags": ["elasticsearch", "monitoring"],+ "default_args": DAG_DEFAULT_ARGS,}diff --git a/catalog/dags/maintenance/rotate_db_snapshots.py b/catalog/dags/maintenance/rotate_db_snapshots.pyindex 19fa84ba9..4c76c4a5a 100644--- a/catalog/dags/maintenance/rotate_db_snapshots.py+++ b/catalog/dags/maintenance/rotate_db_snapshots.py@@ -23,7 +23,7 @@ from airflow.providers.amazon.aws.hooks.rds import RdsHookfrom airflow.providers.amazon.aws.operators.rds import RdsCreateDbSnapshotOperatorfrom airflow.providers.amazon.aws.sensors.rds import RdsSnapshotExistenceSensor-from common.constants import AWS_RDS_CONN_ID+from common.constants import AWS_RDS_CONN_ID, DAG_DEFAULT_ARGSlogger = logging.getLogger(__name__)@@ -86,6 +86,7 @@ def delete_previous_snapshots(db_identifier: str, snapshots_to_retain: int):catchup=False,# Use the docstring at the top of the file as md docs in the UIdoc_md=__doc__,+ default_args=DAG_DEFAULT_ARGS,render_template_as_native_obj=True,)def rotate_db_snapshots():diff --git a/catalog/tests/dags/test_dag_parsing.py b/catalog/tests/dags/test_dag_parsing.pyindex d7232795b..ca2500aa8 100644--- a/catalog/tests/dags/test_dag_parsing.py+++ b/catalog/tests/dags/test_dag_parsing.py@@ -71,3 +71,20 @@ def test_dags_loads_correct_number_with_no_errors(relative_path, tmpdir):dag_bag.process_file(str(DAG_FOLDER / relative_path))assert len(dag_bag.import_errors) == 0, "Errors found during DAG import"assert len(dag_bag.dags) == expected_count, "An unexpected # of DAGs was found"+++def test_dag_uses_default_args():+ # Attempt to load all DAGs in the DAG_FOLDER and check if they use the+ # DAG_DEFAULT_ARGS settings+ dagbag = DagBag(dag_folder=DAG_FOLDER, include_examples=False)++ failures = []+ for dag_id, dag in dagbag.dags.items():+ # An easy proxy for this is checking if DAGs have an on_failure_callback+ on_failure_callback = dag.default_args.get("on_failure_callback")+ if on_failure_callback is None:+ failures.append(dag_id)++ assert (+ not failures+ ), f"The following DAGs do not have DAG_DEFAULT_ARGS defined: {failures}"