environment_check.sh: fix quoting and add timeout
add missing double quotes to a error message
avoid waiting really long time on sles/zypper for checking packages
@@ -71,9 +71,9 @@ detect_node_os()
{
local pod="$1"
- OS=`kubectl exec -it $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID_LIKE=" /etc/os-release | cut -d '=' -f 2'`
+ OS=`kubectl exec -it $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID_LIKE=" /etc/os-release | cut -d= -f2'`
if [[ -z "${OS}" ]]; then
- OS=`kubectl exec -it $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID=" /etc/os-release | cut -d '=' -f 2'`
+ OS=`kubectl exec -it $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID=" /etc/os-release | cut -d= -f2'`
fi
echo "$OS"
}
@@ -90,7 +90,7 @@ set_packages_and_check_cmd()
PACKAGES=(nfs-utils iscsi-initiator-utils)
;;
*"suse"* )
- CHECK_CMD='zypper se -i'
+ CHECK_CMD='rpm -q'
PACKAGES=(nfs-client open-iscsi)
;;
*)
@@ -110,7 +110,7 @@ check_dependencies() {
local target=${targets[$i]}
if [ "$(which $target)" == "" ]; then
allFound=false
- error Not found: $target
+ error "Not found: $target"
fi
done
if [ "$allFound" == "false" ]; then
@@ -223,7 +223,7 @@ check_package_installed() {
for ((i=0; i<${#PACKAGES[@]}; i++)); do
local package=${PACKAGES[$i]}
- kubectl exec -it $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "$CHECK_CMD $package" > /dev/null 2>&1
+ kubectl exec -it $pod -- nsenter --mount=/proc/1/ns/mnt -- timeout 30 bash -c "$CHECK_CMD $package" > /dev/null 2>&1
if [ $? != 0 ]; then
allFound=false
node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName`
