Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(log-cleanup): Argument list too long #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions log-cleanup/airflow-log-cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,23 @@
echo ""
echo "Running Cleanup Process..."

FIND_STATEMENT="find ${BASE_LOG_FOLDER}/*/* -type f -mtime \
# Delete log files
FIND_STATEMENT="find ${BASE_LOG_FOLDER} -type f -mtime \

Choose a reason for hiding this comment

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

Suggested change
FIND_STATEMENT="find ${BASE_LOG_FOLDER} -type f -mtime \
FIND_STATEMENT="find ${BASE_LOG_FOLDER}/* -name ""*"" -type f -mtime \

Choose a reason for hiding this comment

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

this is enough to fix the issue. And find statement for empty folders should be fine

Copy link
Author

Choose a reason for hiding this comment

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

You may commit this change if you want, but I see no difference there. The -name only adds a check which should always be true. Appending the /* should also have no effect, as the -type f check will ensure, we only delete files anyway.

We run this patch internally for quite some time now without any issues.
Deleting around 8k files a day.

Choose a reason for hiding this comment

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

FIND_STATEMENT="find ${BASE_LOG_FOLDER}/* -name ""*"" -type f -mtime \

Thanks a lot!

+${MAX_LOG_AGE_IN_DAYS}"
DELETE_STMT="${FIND_STATEMENT} -exec rm -f {} \;"

cleanup "${FIND_STATEMENT}" "${DELETE_STMT}"
CLEANUP_EXIT_CODE=$?

FIND_STATEMENT="find ${BASE_LOG_FOLDER}/*/* -type d -empty"
# Delete empty DAG run folders
FIND_STATEMENT="find ${BASE_LOG_FOLDER} -type d -empty"
DELETE_STMT="${FIND_STATEMENT} -prune -exec rm -rf {} \;"

cleanup "${FIND_STATEMENT}" "${DELETE_STMT}"
CLEANUP_EXIT_CODE=$?

FIND_STATEMENT="find ${BASE_LOG_FOLDER}/* -type d -empty"
# Delete empty DAG folders
FIND_STATEMENT="find ${BASE_LOG_FOLDER} -type d -empty"
DELETE_STMT="${FIND_STATEMENT} -prune -exec rm -rf {} \;"

cleanup "${FIND_STATEMENT}" "${DELETE_STMT}"
Expand Down