This is an automated email from the ASF dual-hosted git repository.
xddeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 28c21cf clean-logs script for Dockerfile: trim logs before sleep
(#10685)
28c21cf is described below
commit 28c21cfd1ddacc5352ac1d7d149f723c8f5fad30
Author: Kush <[email protected]>
AuthorDate: Sat Sep 5 21:10:57 2020 +0530
clean-logs script for Dockerfile: trim logs before sleep (#10685)
If the pod restarts before the sleep time is over, the trim command will
not run. I think it's better if we reorder the commands to execute the delete
and then go to sleep. At the moment sleep is every 15 mins but people will just
increase the EVERY line if they want longer sleep time and can encounter this
bug.
---
scripts/in_container/prod/clean-logs.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/in_container/prod/clean-logs.sh
b/scripts/in_container/prod/clean-logs.sh
index d05f8a8..c36554a 100755
--- a/scripts/in_container/prod/clean-logs.sh
+++ b/scripts/in_container/prod/clean-logs.sh
@@ -29,9 +29,9 @@ EVERY=$((15*60))
echo "Cleaning logs every $EVERY seconds"
while true; do
- seconds=$(( $(date -u +%s) % EVERY))
- [[ $seconds -lt 1 ]] || sleep $((EVERY - seconds))
-
echo "Trimming airflow logs to ${RETENTION} days."
find "${DIRECTORY}"/logs -mtime +"${RETENTION}" -name '*.log' -delete
+
+ seconds=$(( $(date -u +%s) % EVERY))
+ [[ $seconds -lt 1 ]] || sleep $((EVERY - seconds))
done