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

Bug 1893362: Ensure tail processes exit with parent #859

Merged
merged 1 commit into from Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion bindata/network/openshift-sdn/sdn-ovs.yaml
Expand Up @@ -62,8 +62,14 @@ spec:
if [[ ! -S /run/openvswitch/db.sock ]]; then
systemctl_restart ovsdb-server
fi
# We need to explicitly exit on SIGTERM, see https://github.com/openshift/cluster-dns-operator/issues/65
function quit {
exit 0
}
trap quit SIGTERM
# Don't need to worry about restoring flows; this can only change if we've rebooted
exec tail -F /host/var/log/openvswitch/ovs-vswitchd.log /host/var/log/openvswitch/ovsdb-server.log
tail --pid=$BASHPID -F /host/var/log/openvswitch/ovs-vswitchd.log /host/var/log/openvswitch/ovsdb-server.log &
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why does exec tail ... not exit when it gets a SIGTERM? Shouldn't that always exit? Bash is gone...

Copy link
Member Author

Choose a reason for hiding this comment

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

By default in Linux (possibly Unix in general) pid 1 has SIGTERM set to ignore by default... For basically bad reasons this is still the default with pid namespaces; it clearly would have been better to change it but we can't now.

https://vagga.readthedocs.io/en/latest/pid1mode.html
https://hynek.me/articles/docker-signals/
etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

OHHHHHHHH. Wow.

wait
else

echo "openvswitch is running in container"
Expand Down
9 changes: 8 additions & 1 deletion bindata/network/ovn-kubernetes/006-ovs-node.yaml
Expand Up @@ -75,12 +75,19 @@ spec:
if [[ ! -S /run/openvswitch/db.sock ]]; then
systemctl_restart ovsdb-server
fi
# We need to explicitly exit on SIGTERM, see https://github.com/openshift/cluster-dns-operator/issues/65
function quit {
exit 0
}
trap quit SIGTERM
# Don't need to worry about restoring flows; this can only change if we've rebooted
exec tail -F /host/var/log/openvswitch/ovs-vswitchd.log /host/var/log/openvswitch/ovsdb-server.log
tail --pid=$BASHPID -F /host/var/log/openvswitch/ovs-vswitchd.log /host/var/log/openvswitch/ovsdb-server.log &
wait
else
echo "$(date -Iseconds) - starting ovs-daemons"
chown -R openvswitch:openvswitch /run/openvswitch
chown -R openvswitch:openvswitch /etc/openvswitch
# We need to explicitly exit on SIGTERM, see https://github.com/openshift/cluster-dns-operator/issues/65
function quit {
# Don't allow ovs-vswitchd to clear datapath flows on exit
kill -9 $(cat /var/run/openvswitch/ovs-vswitchd.pid 2>/dev/null) 2>/dev/null || true
Expand Down