n-badtke-cg commented on code in PR #61853:
URL: https://github.com/apache/airflow/pull/61853#discussion_r2803663939


##########
scripts/docker/clean-logs.sh:
##########
@@ -30,11 +31,19 @@ readonly EVERY=$((FREQUENCY*60))
 echo "Cleaning logs every $EVERY seconds"
 
 while true; do
-  echo "Trimming airflow logs to ${RETENTION} days."
-  find "${DIRECTORY}"/logs \
-    -type d -name 'lost+found' -prune -o \
-    -type f -mtime +"${RETENTION}" -name '*.log' -print0 | \
-    xargs -0 rm -f || true
+  if [[ -n "${RETENTION_MINUTES}" ]]; then
+    echo "Trimming airflow logs older than ${RETENTION_MINUTES} minutes."
+    find "${DIRECTORY}"/logs \
+      -type d -name 'lost+found' -prune -o \
+      -type f -mmin +"${RETENTION_MINUTES}" -name '*.log' -print0 | \
+      xargs -0 rm -f || true
+  else
+    echo "Trimming airflow logs older than ${RETENTION_DAYS} days."
+    find "${DIRECTORY}"/logs \
+      -type d -name 'lost+found' -prune -o \
+      -type f -mtime +"${RETENTION_DAYS}" -name '*.log' -print0 | \
+      xargs -0 rm -f || true
+  fi

Review Comment:
   I don't know if it is good practice to just ignore the 
`AIRFLOW__LOG_RETENTION_DAYS` env when `AIRFLOW__LOG_RETENTION_MINUTES` is set. 
This behavior might confuse users. 
   
   Hmm, how about combine `AIRFLOW__LOG_RETENTION_DAYS` and 
`AIRFLOW__LOG_RETENTION_MINUTES`? What I mean with that is this:  
   `AIRFLOW__LOG_RETENTION_DAYS * 24 * 60 + AIRFLOW__LOG_RETENTION_MINUTES`?
   
   With that, it would not be necessary to do an if-else statement, it would be 
enough to just use `-mmin` instead in general.



-- 
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]

Reply via email to