From 837778f389ea96fcce0be9c6effb7ec2d751c088 Mon Sep 17 00:00:00 2001 From: achims311 <1224648+achims311@users.noreply.github.com> Date: Tue, 7 Feb 2023 07:58:24 +0100 Subject: [PATCH] Fix for bug #5304 (second version including POSIX way to call subroutine) (#5314) * Fix for bug #5304. It uses the same technologie to get the kernel release as it was used before to get the os of the node Signed-off-by: Achim Schaefer * used a lower case variable name as suggested by innobead Signed-off-by: Achim Schaefer --------- Signed-off-by: Achim Schaefer Co-authored-by: David Ko (cherry picked from commit 94a23e5b05e0271f6e43f4c4c14d5ad6018b171c) --- scripts/environment_check.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/environment_check.sh b/scripts/environment_check.sh index 042f33b..ad4b509 100755 --- a/scripts/environment_check.sh +++ b/scripts/environment_check.sh @@ -105,6 +105,14 @@ set_packages_and_check_cmd() esac } +detect_node_kernel_release() +{ + local pod="$1" + + KERNEL_RELEASE=$(kubectl exec -i $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'uname -r') + echo "$KERNEL_RELEASE" +} + detect_node_os() { local pod="$1" @@ -321,13 +329,19 @@ check_nfs_client_kernel_support() { declare -A nodes=() for pod in ${pods}; do + local kernel_release=$(detect_node_kernel_release $pod) + if [ x"$kernel_release" == x"" ]; then + error "Unable to detect kernel release on node $node." + exit 2 + fi + node=$(kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName) - res=$(kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^# ${config} is not set\" /boot/config-\$(uname -r)" > /dev/null 2>&1) + res=$(kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^# ${config} is not set\" /boot/config-${kernel_release}" > /dev/null 2>&1) if [[ $? == 0 ]]; then all_found=false nodes["${node}"]="${node}" else - res=$(kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^${config}=\" /boot/config-\$(uname -r)" > /dev/null 2>&1) + res=$(kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^${config}=\" /boot/config-${kernel_release}" > /dev/null 2>&1) if [[ $? != 0 ]]; then all_found=false warn "Unable to check kernel config ${config} on node ${node}"