Skip to content

Add LOG_MAX_SIZE environment variables to log groomer#61559

Merged
potiuk merged 4 commits intoapache:mainfrom
pcorliss:log-cleaner-max-bytes
Feb 15, 2026
Merged

Add LOG_MAX_SIZE environment variables to log groomer#61559
potiuk merged 4 commits intoapache:mainfrom
pcorliss:log-cleaner-max-bytes

Conversation

@pcorliss
Copy link
Contributor

@pcorliss pcorliss commented Feb 6, 2026

Adds two optional environment variables to the clean-logs.sh script to to delete logs once a AIRFLOW__LOG_MAX_SIZE_PERCENT threshold has been breached or a AIRFLOW__LOG_MAX_SIZE_BYTES has been breached. If either environment variable is present and the threshold has been breached the retention days is reduced until the threshold is met and then resets. This makes it easier to avoid out of disk space issues.

airflow-core/tests/unit/charts/log_groomer.py was updated in parallel with helm-tests/tests/chart_utils/log_groomer.py but both files appear to be duplicates of one another. Removing the airflow-core/tests/unit/charts/log_groomer.py files felt out of scope for this PR but I'm happy to delete it if it's no longer in use.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Cursor + Claude Opus 4.5] following the guidelines

The code has been heavily modified after generation and has been reviewed by a human (me). Code has been tested in our local environment.

@boring-cyborg
Copy link

boring-cyborg bot commented Feb 6, 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 area:helm-chart Airflow Helm Chart area:production-image Production image improvements and fixes backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch labels Feb 6, 2026
@pcorliss pcorliss force-pushed the log-cleaner-max-bytes branch from 807d65e to da82a1e Compare February 7, 2026 14:28
@pcorliss
Copy link
Contributor Author

pcorliss commented Feb 7, 2026

I suspect the test failures are due to the following recently fixed issue. I've rebased off latest main branch.

@jscheffl jscheffl added this to the Airflow Helm Chart 1.20.0 milestone Feb 7, 2026
@potiuk
Copy link
Member

potiuk commented Feb 15, 2026

Nice !

@potiuk potiuk merged commit 1e5f789 into apache:main Feb 15, 2026
129 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 15, 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 Feb 15, 2026
…1559)

* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

* Linting fixes
(cherry picked from commit 1e5f789)

Co-authored-by: Philip Corliss <pcorliss@gmail.com>
@github-actions
Copy link

Backport successfully created: v3-1-test

Status Branch Result
v3-1-test PR Link

github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Feb 15, 2026
…ache#61559)

* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

* Linting fixes
(cherry picked from commit 1e5f789)

Co-authored-by: Philip Corliss <pcorliss@gmail.com>
potiuk pushed a commit that referenced this pull request Feb 15, 2026
…1559) (#61950)

* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

* Linting fixes
(cherry picked from commit 1e5f789)

Co-authored-by: Philip Corliss <pcorliss@gmail.com>
n-badtke-cg

This comment was marked as outdated.

fi
fi

find "${DIRECTORY}"/logs -type d -empty -delete || true
Copy link
Contributor

Choose a reason for hiding this comment

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

L65 should be executed before L54

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @n-badtke-cg , I don't quite see the logic bug you're referring to, could you elaborate?

The way I think it works is the following but perhaps I've missed something.

  1. Delete log files based on retention days
  2. If Max size is set and size exceed max size reduce retention days by 1 and go to step 1, otherwise go to step 3.
  3. Delete empty log directories
  4. Sleep

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello @n-badtke-cg , I don't quite see the logic bug you're referring to, could you elaborate?

The way I think it works is the following but perhaps I've missed something.

  1. Delete log files based on retention days
  2. If Max size is set and size exceed max size reduce retention days by 1 and go to step 1, otherwise go to step 3.
  3. Delete empty log directories
  4. Sleep

I guess you are referring to an old message by me "found a logical bug" that was a false message by me, sorry for that!

And also with this message, I just misinterpret the code, sorry. It's actually kinda nice. It's reducing the retention time temporarily to free up more space in specific situations when needed. After the retention period has been temporarily shortened and storage space freed up, the retention period is reset to the env value.

Fair. Again sorry for the unnecessary messages.

choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

* Linting fixes
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

* Linting fixes
vatsrahul1001 pushed a commit that referenced this pull request Mar 4, 2026
…1559) (#61950)

* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

* Linting fixes
(cherry picked from commit 1e5f789)

Co-authored-by: Philip Corliss <pcorliss@gmail.com>
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

* Linting fixes
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
* Add LOG_MAX_SIZE_BYTES option to log cleaner

* Updated clean logs

* Charts updated and tests passing

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

Labels

area:dev-tools area:helm-chart Airflow Helm Chart area:production-image Production image improvements and fixes 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.

4 participants