hkc-8010 commented on code in PR #65239:
URL: https://github.com/apache/airflow/pull/65239#discussion_r3104609515
##########
airflow-core/newsfragments/65239.bugfix.rst:
##########
Review Comment:
Done — removed the newsfragment.
##########
airflow-core/src/airflow/cli/cli_config.py:
##########
@@ -541,6 +541,16 @@ def string_lower_type(val):
"Lower values reduce long-running locks but increase the number of
batches."
),
)
+ARG_DB_ERROR_ON_CLEANUP_FAILURE = Arg(
+ ("--error-on-cleanup-failure",),
+ help=(
+ "If set, the command will exit with a non-zero exit code if any table
cleanup encountered "
+ "an error. By default errors are suppressed and the command exits 0
even if some tables "
+ "were not cleaned. Recommended when running airflow db clean from a
DAG or automated "
+ "workflow so that failures are surfaced rather than silently skipped."
Review Comment:
Done — simplified to a single concise sentence.
##########
airflow-core/src/airflow/utils/db_cleanup.py:
##########
@@ -613,9 +631,22 @@ def run_cleanup(
batch_size=batch_size,
)
session.commit()
+ if ctx.failed:
+ failed_tables.append(table_name)
else:
logger.warning("Table %s not found. Skipping.", table_name)
+ if failed_tables:
+ logger.warning(
+ "The following tables were not cleaned due to errors: %s. Check
the logs above for details.",
+ failed_tables,
+ )
+ if error_on_cleanup_failure:
+ raise AirflowException(
Review Comment:
Done — replaced with `RuntimeError`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]