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 <[email protected]>
  • Loading branch information
LALLAU Bertrand committed Sep 3, 2024
1 parent d62dc56 commit a519547
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 a519547

Please sign in to comment.