mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #88181 from BenTheElder/healthier-monitor
fix shellcheck failures in health-monitor.sh
This commit is contained in:
commit
d58216a253
@ -33,22 +33,22 @@ function container_runtime_monitoring {
|
|||||||
# dockershim is still part of kubelet today. When kubelet is down, crictl pods
|
# dockershim is still part of kubelet today. When kubelet is down, crictl pods
|
||||||
# will also fail, and docker will be killed. This is undesirable especially when
|
# will also fail, and docker will be killed. This is undesirable especially when
|
||||||
# docker live restore is disabled.
|
# docker live restore is disabled.
|
||||||
local healthcheck_command="docker ps"
|
local healthcheck_command=(docker ps)
|
||||||
if [[ "${CONTAINER_RUNTIME:-docker}" != "docker" ]]; then
|
if [[ "${CONTAINER_RUNTIME:-docker}" != "docker" ]]; then
|
||||||
healthcheck_command="${crictl} pods"
|
healthcheck_command=("${crictl}" pods)
|
||||||
fi
|
fi
|
||||||
# Container runtime startup takes time. Make initial attempts before starting
|
# Container runtime startup takes time. Make initial attempts before starting
|
||||||
# killing the container runtime.
|
# killing the container runtime.
|
||||||
until timeout 60 ${healthcheck_command} > /dev/null; do
|
until timeout 60 "${healthcheck_command[@]}" > /dev/null; do
|
||||||
if (( attempt == max_attempts )); then
|
if (( attempt == max_attempts )); then
|
||||||
echo "Max attempt ${max_attempts} reached! Proceeding to monitor container runtime healthiness."
|
echo "Max attempt ${max_attempts} reached! Proceeding to monitor container runtime healthiness."
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
echo "$attempt initial attempt \"${healthcheck_command}\"! Trying again in $attempt seconds..."
|
echo "$attempt initial attempt \"${healthcheck_command[*]}\"! Trying again in $attempt seconds..."
|
||||||
sleep "$(( 2 ** attempt++ ))"
|
sleep "$(( 2 ** attempt++ ))"
|
||||||
done
|
done
|
||||||
while true; do
|
while true; do
|
||||||
if ! timeout 60 ${healthcheck_command} > /dev/null; then
|
if ! timeout 60 "${healthcheck_command[@]}" > /dev/null; then
|
||||||
echo "Container runtime ${container_runtime_name} failed!"
|
echo "Container runtime ${container_runtime_name} failed!"
|
||||||
if [[ "$container_runtime_name" == "docker" ]]; then
|
if [[ "$container_runtime_name" == "docker" ]]; then
|
||||||
# Dump stack of docker daemon for investigation.
|
# Dump stack of docker daemon for investigation.
|
||||||
@ -71,10 +71,10 @@ function kubelet_monitoring {
|
|||||||
sleep 120
|
sleep 120
|
||||||
local -r max_seconds=10
|
local -r max_seconds=10
|
||||||
local output=""
|
local output=""
|
||||||
while [ 1 ]; do
|
while true; do
|
||||||
if ! output=$(curl -m "${max_seconds}" -f -s -S http://127.0.0.1:10248/healthz 2>&1); then
|
if ! output=$(curl -m "${max_seconds}" -f -s -S http://127.0.0.1:10248/healthz 2>&1); then
|
||||||
# Print the response and/or errors.
|
# Print the response and/or errors.
|
||||||
echo $output
|
echo "${output}"
|
||||||
echo "Kubelet is unhealthy!"
|
echo "Kubelet is unhealthy!"
|
||||||
systemctl kill kubelet
|
systemctl kill kubelet
|
||||||
# Wait for a while, as we don't want to kill it again before it is really up.
|
# Wait for a while, as we don't want to kill it again before it is really up.
|
||||||
@ -108,5 +108,5 @@ if [[ "${component}" == "container-runtime" ]]; then
|
|||||||
elif [[ "${component}" == "kubelet" ]]; then
|
elif [[ "${component}" == "kubelet" ]]; then
|
||||||
kubelet_monitoring
|
kubelet_monitoring
|
||||||
else
|
else
|
||||||
echo "Health monitoring for component "${component}" is not supported!"
|
echo "Health monitoring for component \"${component}\" is not supported!"
|
||||||
fi
|
fi
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
./cluster/gce/config-test.sh
|
./cluster/gce/config-test.sh
|
||||||
./cluster/gce/gci/configure-helper.sh
|
./cluster/gce/gci/configure-helper.sh
|
||||||
./cluster/gce/gci/configure.sh
|
./cluster/gce/gci/configure.sh
|
||||||
./cluster/gce/gci/health-monitor.sh
|
|
||||||
./cluster/gce/gci/master-helper.sh
|
./cluster/gce/gci/master-helper.sh
|
||||||
./cluster/gce/upgrade.sh
|
./cluster/gce/upgrade.sh
|
||||||
./cluster/gce/util.sh
|
./cluster/gce/util.sh
|
||||||
|
Loading…
Reference in New Issue
Block a user