Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

Commit

Permalink
Fixed concurrent run of helm-tiller: save pid to file in temporary di…
Browse files Browse the repository at this point in the history
…rectory, kill tiller by pid file
  • Loading branch information
excavador committed Sep 18, 2019
1 parent a36d46d commit 9a6beef
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions scripts/tiller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,28 @@ tiller_env() {
fi
}
tiller_pid_file() {
echo "$TMPDIR/helm-tiller-${HELM_TILLER_PORT}.pid"
}
tiller_save_pid() {
local tiller_pid="$1"
local tiller_pid_file
tiller_pid_file=$(tiller_pid_file)
echo "$tiller_pid" > "$tiller_pid_file"
}
start_tiller() {
tiller_env
PROBE_LISTEN_FLAG="--probe-listen=127.0.0.1:${HELM_TILLER_PROBE_PORT}"
# check if we have a version that supports the --probe-listen flag
./bin/tiller --help 2>&1 | grep probe-listen > /dev/null || PROBE_LISTEN_FLAG=""
# shellcheck disable=SC2188
( ./bin/tiller --storage=${HELM_TILLER_STORAGE} --listen=127.0.0.1:${HELM_TILLER_PORT} ${PROBE_LISTEN_FLAG} --history-max=${HELM_TILLER_HISTORY_MAX} & 2>"${HELM_TILLER_LOGS_DIR}")
if [[ "${HELM_TILLER_SILENT}" == "false" ]]; then
(
./bin/tiller --storage=${HELM_TILLER_STORAGE} --listen=127.0.0.1:${HELM_TILLER_PORT} ${PROBE_LISTEN_FLAG} --history-max=${HELM_TILLER_HISTORY_MAX} &
tiller_save_pid "$!"
) 2>"${HELM_TILLER_LOGS_DIR}"
if [[ "${HELM_TILLER_SILENT}" == "false" ]]; then
echo "Tiller namespace: $TILLER_NAMESPACE"
fi
}
Expand All @@ -176,7 +190,16 @@ stop_tiller() {
if [[ "${HELM_TILLER_SILENT}" == "false" ]]; then
echo "Stopping Tiller..."
fi
pkill -9 -f ./bin/tiller
local tiller_pid_file
tiller_pid_file=$(tiller_pid_file)
if ! [ -f "$tiller_pid_file" ]; then
echo "can not find tiller pid file $tiller_pid_file" 1>&2
exit 1
fi
local tiller_pid
tiller_pid="$(cat "$tiller_pid_file")"
kill -9 "$tiller_pid"
rm -f "$tiller_pid_file"
}
COMMAND=$1
Expand Down

0 comments on commit 9a6beef

Please sign in to comment.