Browse Source

Update kubelet patch restarting script to check running version

This adds a version check to kubelet patch restarting script.
This will only restart kubelet if the running kubelet is v1.21.8.

This script requires modification depending on specific kubelet
versions that are actually being patched.

TESTING:
- PASS: Verified restart of kubelet and isolcpus_plugin services
        with designer patch install and remove for only v1.21.8

Story: 2008760
Task: 44541

Signed-off-by: Jim Gauld <james.gauld@windriver.com>
Change-Id: I335f2a2e088ead55d32749c07e217a96d53c09a3
changes/11/831611/2
Jim Gauld 4 months ago
parent
commit
56e4a7de45
  1. 26
      patch-scripts/EXAMPLE_KUBELET/scripts/kubelet-restart-example

26
patch-scripts/EXAMPLE_KUBELET/scripts/kubelet-restart-example

@ -26,6 +26,12 @@
#
declare -i GLOBAL_RC=$PATCH_STATUS_OK
#
# Declare subset of kubernetes versions we want to patch.
# This is customized for the particular patch.
#
declare -a PATCH_RESTART_VERSIONS=( "v1.21.8" )
# kubelet doesn't run on storage nodes
if is_storage
then
@ -38,6 +44,26 @@ then
systemctl status kubelet.service|grep -q "Active: active (running)"
if [ $? -eq 0 ]
then
# Obtain current kubelet version
KVER=$(kubectl version --short=true 2>/dev/null | grep -oP 'Client Version: \K\S+')
# Check current kubelet version matches any expected restart versions
FOUND=0
for val in ${PATCH_RESTART_VERSIONS[@]}; do
if [ "${val}" == "${KVER}" ]; then
FOUND=1
break
fi
done
if [ ${FOUND} -eq 1 ]; then
loginfo "$0: Current kubelet ${KVER} found in: ${PATCH_RESTART_VERSIONS[@]}"
else
# do not restart versions that do not require patching
loginfo "$0: Current kubelet ${KVER} not found in" \
"${PATCH_RESTART_VERSIONS[@]}, skipping kubelet restart"
exit $GLOBAL_RC
fi
# issue a systemd daemon-reload once the rpms have been installed
# and before the processes have been restarted.
systemctl daemon-reload

Loading…
Cancel
Save