environment check: precisely check kernel option

Longhorn 3157

Signed-off-by: Derek Su <derek.su@suse.com>
This commit is contained in:
Derek Su 2022-12-26 19:29:26 +08:00 committed by David Ko
parent c83497b685
commit 62998adab2

View File

@ -318,19 +318,19 @@ check_nfs_client_kernel_support() {
local nfs_client_kernel_configs=("CONFIG_NFS_V4_1" "CONFIG_NFS_V4_2") local nfs_client_kernel_configs=("CONFIG_NFS_V4_1" "CONFIG_NFS_V4_2")
for config in "${nfs_client_kernel_configs[@]}"; do for config in "${nfs_client_kernel_configs[@]}"; do
declare -A nodes declare -A nodes=()
for pod in ${pods}; do for pod in ${pods}; do
node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName` 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 if [[ $? == 0 ]]; then
all_found=false all_found=false
nodes["${node}"]="${node}" nodes["${node}"]="${node}"
else 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 if [[ $? != 0 ]]; then
all_found=false all_found=false
warn "Unable to check kernel config ${config}" warn "Unable to check kernel config ${config} on node ${node}"
fi fi
fi fi
done done