Skip to content

feat(docker): add minute-level log retention to clean-logs script#61855

Merged
jscheffl merged 6 commits intoapache:mainfrom
pugarte7:feat/docker-minute-log-retention
Mar 11, 2026
Merged

feat(docker): add minute-level log retention to clean-logs script#61855
jscheffl merged 6 commits intoapache:mainfrom
pugarte7:feat/docker-minute-log-retention

Conversation

@pugarte7
Copy link
Contributor

@pugarte7 pugarte7 commented Feb 13, 2026

What does this PR support?

I’m adding the possibility to define an environment variable to clean logs on a minute basis instead of just days, which is how it works right now.

New variable: AIRFLOW__LOG_RETENTION_MINUTES

Why?

Many users, like @n-badtke-cg (the issue opener), needed a more atomic way of getting rid of logs. In big projects, waiting a full day to clean logs isn't optimal, as the files pile up so fast that it makes debugging difficult and storage expensive.

How?

I’ve updated scripts/docker/clean-logs.sh with some conditional logic:

If AIRFLOW__LOG_RETENTION_MINUTES is set and bigger than 0, the script uses find -mmin.

Otherwise, it falls back to the existing -mtime (day-based) logic.
The default is 0, so nothing changes for users unless they opt-in. This also makes it easy to "rollback" to daily cleanup just by setting the minutes back to 0.

Backward Compatibility

There are no breaking changes here. I’ve maintained the existing logic, and the new minute-level option follows the exact same structure that’s already there. If you don't touch the new variable, Airflow behaves exactly as it did before.

Testing

I verified this locally by creating test log files.
Confirmed that it deletes files correctly based on minute-level thresholds.
Confirmed it still falls back to day-based retention when the minute variable is 0 or unset.

Co-authored-by: shreeharshshinde shreeharshshinde@users.noreply.github.com

Closes #61814

@boring-cyborg
Copy link

boring-cyborg bot commented Feb 13, 2026

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@boring-cyborg boring-cyborg bot added area:dev-tools backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch labels Feb 13, 2026
@n-badtke-cg
Copy link
Contributor

Duplication with #61853

@pugarte7 pugarte7 force-pushed the feat/docker-minute-log-retention branch from 5483b2f to 772b333 Compare March 6, 2026 10:43
@potiuk
Copy link
Member

potiuk commented Mar 10, 2026

@Wastelander777 This PR has been converted to draft because it does not yet meet our Pull Request quality criteria.

Issues found:

  • mypy (type checking): Failing: CI image checks / MyPy checks (mypy-providers). Run prek --stage manual mypy-providers --all-files locally to reproduce. You need breeze ci-image build --python 3.10 for Docker-based mypy. See mypy (type checking) docs.
  • Build docs: Failing: CI image checks / Build documentation (--docs-only). Run breeze build-docs locally to reproduce. See Build docs docs.
  • Other failing CI checks: Failing: CI image checks / Build documentation (--spellcheck-only). Run prek run --from-ref main locally to reproduce. See static checks docs.

Note: Your branch is 177 commits behind main. Some check failures may be caused by changes in the base branch rather than by your PR. Please rebase your branch and push again to get up-to-date CI results.

What to do next:

  • The comment informs you what you need to do.
  • Fix each issue, then mark the PR as "Ready for review" in the GitHub UI - but only after making sure that all the issues are fixed.
  • Maintainers will then proceed with a normal review.

Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. If you have questions, feel free to ask on the Airflow Slack.

@pugarte7 pugarte7 force-pushed the feat/docker-minute-log-retention branch from e296f06 to 61d4562 Compare March 11, 2026 12:39
@pugarte7 pugarte7 marked this pull request as ready for review March 11, 2026 13:01
@pugarte7
Copy link
Contributor Author

Hi @n-badtke-cg @potiuk !! I have addressed the comments, and the code is passing the CI issues, it should be ready to merge. Feel free to request anything else. Thank you!

@pugarte7 pugarte7 requested a review from n-badtke-cg March 11, 2026 13:04
@n-badtke-cg
Copy link
Contributor

Duplication with #61853

This PR is currently the most progressed one.

@jscheffl jscheffl added this to the Airflow Helm Chart 1.20.0 milestone Mar 11, 2026
@jscheffl jscheffl merged commit de01a6b into apache:main Mar 11, 2026
235 of 236 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 11, 2026

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

github-actions bot pushed a commit that referenced this pull request Mar 11, 2026
…s script (#61855)

* feat(docker): add minute-level log retention support to clean-logs.sh

* feat(docker): import coauthored changes

* update inlined scripts in Dockerfile

* comments fixed
(cherry picked from commit de01a6b)

Co-authored-by: Pablo Ugarte <99680272+Wastelander777@users.noreply.github.com>
@github-actions
Copy link

Backport successfully created: v3-1-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-1-test PR Link

@@ -45,10 +46,12 @@ fi
retention_days="${RETENTION}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug here = RETENTION is sttill used here @Wastelander777

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups, my bad 😣. What should be the approach? How can I fix that? Do I re-open the issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, went over my head too :/

Do I re-open the issue?

no, the PR is already merged, there needs to be a new PR unfortunately

@potiuk
Copy link
Member

potiuk commented Mar 11, 2026

@jscheffl -> I was just about to post this comment before you merged :)

@jscheffl
Copy link
Contributor

@jscheffl -> I was just about to post this comment before you merged :)

Sorry... are you on a correction or shall I?

dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
…ache#61855)

* feat(docker): add minute-level log retention support to clean-logs.sh

* feat(docker): import coauthored changes

* update inlined scripts in Dockerfile

* comments fixed
PascalEgn pushed a commit to PascalEgn/airflow that referenced this pull request Mar 12, 2026
…ache#61855)

* feat(docker): add minute-level log retention support to clean-logs.sh

* feat(docker): import coauthored changes

* update inlined scripts in Dockerfile

* comments fixed
Copy link
Contributor

@n-badtke-cg n-badtke-cg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answer

@@ -45,10 +46,12 @@ fi
retention_days="${RETENTION}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, went over my head too :/

Do I re-open the issue?

no, the PR is already merged, there needs to be a new PR unfortunately

@n-badtke-cg
Copy link
Contributor

I created PR #63421

@n-badtke-cg
Copy link
Contributor

n-badtke-cg commented Mar 12, 2026

Issues fixed with merge of #63421

Pyasma pushed a commit to Pyasma/airflow that referenced this pull request Mar 13, 2026
…ache#61855)

* feat(docker): add minute-level log retention support to clean-logs.sh

* feat(docker): import coauthored changes

* update inlined scripts in Dockerfile

* comments fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Container Log Groomer should be configurable with a log retention time <1d - OTEL Collector FileLogReceiver

4 participants