From 62998adab26c67b4739cf336ff19f636e80d0459 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Mon, 26 Dec 2022 19:29:26 +0800 Subject: [PATCH] environment check: precisely check kernel option Longhorn 3157 Signed-off-by: Derek Su --- scripts/environment_check.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/environment_check.sh b/scripts/environment_check.sh index 60d21df..7527991 100755 --- a/scripts/environment_check.sh +++ b/scripts/environment_check.sh @@ -318,19 +318,19 @@ check_nfs_client_kernel_support() { local nfs_client_kernel_configs=("CONFIG_NFS_V4_1" "CONFIG_NFS_V4_2") for config in "${nfs_client_kernel_configs[@]}"; do - declare -A nodes + declare -A nodes=() for pod in ${pods}; do 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}\" /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-$(uname -r)" > /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-$(uname -r)" > /dev/null 2>&1` if [[ $? != 0 ]]; then all_found=false - warn "Unable to check kernel config ${config}" + warn "Unable to check kernel config ${config} on node ${node}" fi fi done