Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock induced MacOS PW Pool collapse #214

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion mac_pw_pool/nightly_maintenance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ if [[ ! -r "$CRONLOG" ]] || [[ ! -r "$CRONSCRIPT" ]] || [[ ! -d "../.git" ]]; th
fi

relaunch_web_container() {
# Assume code has changed, restart container w/ latest image
# Assume code change or image update, restart container.
(
# Prevent podman and/or sub-processes from inheriting the lock FD.
# This would deadlock all future runs of this script or Cron.sh
# Can't use `flock --close ...` here because it "hangs" in this context.
for fd_nr in $(/bin/ls /proc/self/fd/); do
[[ $fd_nr -ge 3 ]] || \
continue
Comment on lines +31 to +32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this usage? Why not a simple if? (Just curious. My brain does not process test || as easily as it does if/then).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed I also find if else easier to read in scripts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My brain has an easier time understanding this as a "filter", "only greater/equal to 3 may proceed". If it were a more complex condition in a different context, I'd probably agree with you though 😄

# Bash doesn't allow direct substitution of the FD number
eval "exec $fd_nr>&-"
done

set -x

podman run --replace --name "$_CNTNAME" -d --rm --pull=newer -p 8080:80 \
-v $HOME/devel/automation/mac_pw_pool/html:/usr/share/nginx/html:ro,Z \
$WEB_IMG
Expand Down