Skip to content

Commit

Permalink
Fix CPU burning on ironic-log-watch when no ramdisk file is present
Browse files Browse the repository at this point in the history
Use inotifywait on 'close_write' event instead of an infinite loop.
Inotifywait 'close_write' event usage allow to be sure that
tar file archive integrity is safe.

Signed-off-by: LALLAU Bertrand <blallau@github.com>
  • Loading branch information
LALLAU Bertrand committed Sep 2, 2024
1 parent d62dc56 commit f06b9b5
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions scripts/runlogwatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
# Ramdisk logs path
LOG_DIR="/shared/log/ironic/deploy"

while :; do
if ! ls "${LOG_DIR}"/*.tar.gz 1> /dev/null 2>&1; then
continue
fi

for fn in "${LOG_DIR}"/*.tar.gz; do
echo "************ Contents of $fn ramdisk log file bundle **************"
tar -xOzvvf "$fn" | sed -e "s/^/$(basename "$fn"): /"
rm -f "$fn"
inotifywait -m "$LOG_DIR" -e close_write |
while read -r path action file; do
echo "************ Contents of $path/$file ramdisk log file bundle **************"
tar -xOzvvf "$path/$file" | sed -e "s/^/$file: /"
rm -f "$path/$file"
done

sleep 5
done

0 comments on commit f06b9b5

Please sign in to comment.