mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Attempt to delete the runner before shutting down
This commit is contained in:
parent
538d1f7c17
commit
da37f32d4b
@ -12,7 +12,8 @@ echo "Running init script"
|
|||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
export RUNNER_HOME=/home/ubuntu/actions-runner
|
export RUNNER_HOME=/home/ubuntu/actions-runner
|
||||||
|
|
||||||
export RUNNER_URL="https://github.com/ClickHouse"
|
export RUNNER_ORG="ClickHouse"
|
||||||
|
export RUNNER_URL="https://github.com/${RUNNER_ORG}"
|
||||||
# Funny fact, but metadata service has fixed IP
|
# Funny fact, but metadata service has fixed IP
|
||||||
INSTANCE_ID=$(ec2metadata --instance-id)
|
INSTANCE_ID=$(ec2metadata --instance-id)
|
||||||
export INSTANCE_ID
|
export INSTANCE_ID
|
||||||
@ -282,18 +283,11 @@ while true; do
|
|||||||
RUNNER_AGE=$(( $(date +%s) - $(stat -c +%Y /proc/"$runner_pid" 2>/dev/null || date +%s) ))
|
RUNNER_AGE=$(( $(date +%s) - $(stat -c +%Y /proc/"$runner_pid" 2>/dev/null || date +%s) ))
|
||||||
echo "The runner is launched $RUNNER_AGE seconds ago and still has hot received the job"
|
echo "The runner is launched $RUNNER_AGE seconds ago and still has hot received the job"
|
||||||
if (( 60 < RUNNER_AGE )); then
|
if (( 60 < RUNNER_AGE )); then
|
||||||
echo "Check if the instance should tear down"
|
echo "Attempt to delete the runner for a graceful shutdown"
|
||||||
if ! no_terminating_metadata; then
|
sudo -u ubuntu ./config.sh remove --token "$(get_runner_token)" \
|
||||||
# Another check if the worker still didn't start
|
|| continue
|
||||||
if is_job_assigned; then
|
echo "Runner didn't launch or have assigned jobs after ${RUNNER_AGE} seconds, shutting down"
|
||||||
echo "During the metadata check the job was assigned, continue"
|
terminate_and_exit
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# shellcheck disable=SC2046
|
|
||||||
kill -9 $(list_children "$runner_pid")
|
|
||||||
sudo -u ubuntu ./config.sh remove --token "$(get_runner_token)"
|
|
||||||
terminate_on_event
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
sleep 5
|
sleep 5
|
||||||
|
Loading…
Reference in New Issue
Block a user