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

Adds a trap for SIGTERM in entrypoint script #608

Merged
merged 1 commit into from
Feb 9, 2021
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
17 changes: 12 additions & 5 deletions images/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
# Always exit on errors.
set -e

# Trap sigterm
function exitonsigterm() {
echo "Trapped sigterm, exiting."
exit 0
}
trap exitonsigterm SIGTERM

# Set our known directories.
CNI_CONF_DIR="/host/etc/cni/net.d"
CNI_BIN_DIR="/host/opt/cni/bin"
Expand Down Expand Up @@ -246,7 +253,7 @@ if [ "$MULTUS_CONF_FILE" == "auto" ]; then
log "Attemping to find master plugin configuration, attempt $tries"
fi
let "tries+=1"
sleep 1;
sleep 1 & wait;
else
error "Multus could not be configured: no master plugin was found."
exit 1;
Expand Down Expand Up @@ -390,22 +397,22 @@ if [ "$MULTUS_CLEANUP_CONFIG_ON_EXIT" == true ]; then
# Check and see if the original master plugin configuration exists...
if [ ! -f "$MASTER_PLUGIN_LOCATION" ]; then
log "Master plugin @ $MASTER_PLUGIN_LOCATION has been deleted. Allowing 45 seconds for its restoration..."
sleep 10
sleep 10 & wait
for i in {1..35}
do
if [ -f "$MASTER_PLUGIN_LOCATION" ]; then
log "Master plugin @ $MASTER_PLUGIN_LOCATION was restored. Regenerating given configuration."
break
fi
sleep 1
sleep 1 & wait
done

generateMultusConf
log "Continuing watch loop after configuration regeneration..."
fi
sleep 1
sleep 1 & wait
done
else
log "Entering sleep (success)..."
sleep infinity
sleep infinity & wait
fi