Skip to content

Commit

Permalink
Merge pull request #607 from elfosardo/pyinotify
Browse files Browse the repository at this point in the history
🌱 Use pynotify instead of inotify-tools
  • Loading branch information
metal3-io-bot authored Jan 7, 2025
2 parents 8c48d47 + 9f70030 commit 87c1b28
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
1 change: 1 addition & 0 deletions main-packages-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ipmitool
iproute
mod_ssl
procps
python3-inotify
python3-jinja2
qemu-img
sqlite
Expand Down
4 changes: 0 additions & 4 deletions prepare-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ if [[ -n "${EXTRA_PKGS_LIST:-}" ]]; then
fi
fi

dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf config-manager --set-disabled epel
dnf install -y --enablerepo=epel inotify-tools

dnf remove -y --noautoremove 'dnf-command(config-manager)'

# NOTE(elfosardo): we need to reinstall tzdata as the base CS9 container removes
Expand Down
16 changes: 8 additions & 8 deletions scripts/runhttpd
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ fi

# Set up inotify to kill the container (restart) whenever cert files for ironic api change
if [[ "$IRONIC_TLS_SETUP" == "true" ]] && [[ "${RESTART_CONTAINER_CERTIFICATE_UPDATED}" == "true" ]]; then
# shellcheck disable=SC2034
inotifywait -m -e delete_self "${IRONIC_CERT_FILE}" | while read -r file event; do
kill -WINCH $(pgrep httpd)
done &
python3 -m pyinotify -e IN_DELETE_SELF -v "${IRONIC_CERT_FILE}" |
while read -r file event; do
kill -WINCH $(pgrep httpd)
done &
fi

# Set up inotify to kill the container (restart) whenever cert of httpd for /shared/html/<redifsh;ilo> path change
if [[ "$IRONIC_VMEDIA_TLS_SETUP" == "true" ]] && [[ "${RESTART_CONTAINER_CERTIFICATE_UPDATED}" == "true" ]]; then
# shellcheck disable=SC2034
inotifywait -m -e delete_self "${IRONIC_VMEDIA_CERT_FILE}" | while read -r file event; do
kill -WINCH $(pgrep httpd)
done &
python3 -m pyinotify -e IN_DELETE_SELF -v "${IRONIC_VMEDIA_CERT_FILE}" |
while read -r file event; do
kill -WINCH $(pgrep httpd)
done &
fi

exec /usr/sbin/httpd -DFOREGROUND
8 changes: 4 additions & 4 deletions scripts/runironic
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ mkdir -p /shared/log/ironic/deploy
run_ironic_dbsync

if [[ "$IRONIC_TLS_SETUP" == "true" ]] && [[ "${RESTART_CONTAINER_CERTIFICATE_UPDATED}" == "true" ]]; then
# shellcheck disable=SC2034
inotifywait -m -e delete_self "${IRONIC_CERT_FILE}" | while read -r file event; do
kill $(pgrep ironic)
done &
python3 -m pyinotify -e IN_DELETE_SELF -v "${IRONIC_CERT_FILE}" |
while read -r file event; do
kill $(pgrep ironic)
done &
fi

configure_ironic_auth
Expand Down
2 changes: 1 addition & 1 deletion scripts/runlogwatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Ramdisk logs path
LOG_DIR="/shared/log/ironic/deploy"

inotifywait -m "${LOG_DIR}" -e close_write |
python3 -m pyinotify -e IN_CLOSE_WRITE -v "${LOG_DIR}" |
while read -r path _action file; do
echo "************ Contents of ${path}/${file} ramdisk log file bundle **************"
tar -xOzvvf "${path}/${file}" | sed -e "s/^/${file}: /"
Expand Down

0 comments on commit 87c1b28

Please sign in to comment.