diff --git a/chart/Chart.yaml b/chart/Chart.yaml index c04f908..e3d1122 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: longhorn -version: 1.2.4 -appVersion: v1.2.4 +version: 1.2.5-rc1 +appVersion: v1.2.5-rc1 kubeVersion: ">=1.18.0-0" description: Longhorn is a distributed block storage system for Kubernetes. keywords: diff --git a/chart/values.yaml b/chart/values.yaml index 08a4854..c566ca9 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -25,13 +25,13 @@ image: longhorn: engine: repository: longhornio/longhorn-engine - tag: v1.2.4 + tag: v1.2.5-rc1 manager: repository: longhornio/longhorn-manager - tag: v1.2.4 + tag: v1.2.5-rc1 ui: repository: longhornio/longhorn-ui - tag: v1.2.4 + tag: v1.2.5-rc1 instanceManager: repository: longhornio/longhorn-instance-manager tag: v1_20220303 diff --git a/deploy/longhorn-images.txt b/deploy/longhorn-images.txt index 1fc6a3a..530c7f6 100644 --- a/deploy/longhorn-images.txt +++ b/deploy/longhorn-images.txt @@ -4,8 +4,8 @@ longhornio/csi-resizer:v1.2.0 longhornio/csi-snapshotter:v3.0.3 longhornio/csi-node-driver-registrar:v2.3.0 longhornio/backing-image-manager:v2_20210820 -longhornio/longhorn-engine:v1.2.4 +longhornio/longhorn-engine:v1.2.5-rc1 longhornio/longhorn-instance-manager:v1_20220303 -longhornio/longhorn-manager:v1.2.4 +longhornio/longhorn-manager:v1.2.5-rc1 longhornio/longhorn-share-manager:v1_20211020 -longhornio/longhorn-ui:v1.2.4 +longhornio/longhorn-ui:v1.2.5-rc1 diff --git a/deploy/longhorn.yaml b/deploy/longhorn.yaml index fa81d7d..ad9e535 100644 --- a/deploy/longhorn.yaml +++ b/deploy/longhorn.yaml @@ -948,7 +948,7 @@ spec: spec: containers: - name: longhorn-manager - image: longhornio/longhorn-manager:v1.2.4 + image: longhornio/longhorn-manager:v1.2.5-rc1 imagePullPolicy: IfNotPresent securityContext: privileged: true @@ -957,7 +957,7 @@ spec: - -d - daemon - --engine-image - - longhornio/longhorn-engine:v1.2.4 + - longhornio/longhorn-engine:v1.2.5-rc1 - --instance-manager-image - longhornio/longhorn-instance-manager:v1_20220303 - --share-manager-image @@ -965,7 +965,7 @@ spec: - --backing-image-manager-image - longhornio/backing-image-manager:v2_20210820 - --manager-image - - longhornio/longhorn-manager:v1.2.4 + - longhornio/longhorn-manager:v1.2.5-rc1 - --service-account - longhorn-service-account ports: @@ -1079,7 +1079,7 @@ spec: spec: containers: - name: longhorn-ui - image: longhornio/longhorn-ui:v1.2.4 + image: longhornio/longhorn-ui:v1.2.5-rc1 imagePullPolicy: IfNotPresent volumeMounts: - name : nginx-cache @@ -1147,18 +1147,18 @@ spec: spec: initContainers: - name: wait-longhorn-manager - image: longhornio/longhorn-manager:v1.2.4 + image: longhornio/longhorn-manager:v1.2.5-rc1 command: ['sh', '-c', 'while [ $(curl -m 1 -s -o /dev/null -w "%{http_code}" http://longhorn-backend:9500/v1) != "200" ]; do echo waiting; sleep 2; done'] containers: - name: longhorn-driver-deployer - image: longhornio/longhorn-manager:v1.2.4 + image: longhornio/longhorn-manager:v1.2.5-rc1 imagePullPolicy: IfNotPresent command: - longhorn-manager - -d - deploy-driver - --manager-image - - longhornio/longhorn-manager:v1.2.4 + - longhornio/longhorn-manager:v1.2.5-rc1 - --manager-url - http://longhorn-backend:9500/v1 env: diff --git a/scripts/environment_check.sh b/scripts/environment_check.sh index 70ae982..74795d0 100755 --- a/scripts/environment_check.sh +++ b/scripts/environment_check.sh @@ -1,18 +1,123 @@ #!/bin/bash -dependencies() { +export RED='\x1b[0;31m' +export GREEN='\x1b[38;5;22m' +export CYAN='\x1b[36m' +export YELLOW='\x1b[33m' +export NO_COLOR='\x1b[0m' + +if [ -z "${LOG_TITLE}" ]; then + LOG_TITLE='' +fi +if [ -z "${LOG_LEVEL}" ]; then + LOG_LEVEL="INFO" +fi + +debug() { + if [[ "${LOG_LEVEL}" == "DEBUG" ]]; then + local log_title + if [ -n "${LOG_TITLE}" ]; then + log_title="(${LOG_TITLE})" + else + log_title='' + fi + echo -e "${GREEN}[DEBUG]${log_title} ${NO_COLOR}$1" + fi +} + +info() { + if [[ "${LOG_LEVEL}" == "DEBUG" ]] ||\ + [[ "${LOG_LEVEL}" == "INFO" ]]; then + local log_title + if [ -n "${LOG_TITLE}" ]; then + log_title="(${LOG_TITLE})" + else + log_title='' + fi + echo -e "${CYAN}[INFO] ${log_title} ${NO_COLOR}$1" + fi +} + +warn() { + if [[ "${LOG_LEVEL}" == "DEBUG" ]] ||\ + [[ "${LOG_LEVEL}" == "INFO" ]] ||\ + [[ "${LOG_LEVEL}" == "WARN" ]]; then + local log_title + if [ -n "${LOG_TITLE}" ]; then + log_title="(${LOG_TITLE})" + else + log_title='' + fi + echo -e "${YELLOW}[WARN] ${log_title} ${NO_COLOR}$1" + fi +} + +error() { + if [[ "${LOG_LEVEL}" == "DEBUG" ]] ||\ + [[ "${LOG_LEVEL}" == "INFO" ]] ||\ + [[ "${LOG_LEVEL}" == "WARN" ]] ||\ + [[ "${LOG_LEVEL}" == "ERROR" ]]; then + local log_title + if [ -n "${LOG_TITLE}" ]; then + log_title="(${LOG_TITLE})" + else + log_title='' + fi + echo -e "${RED}[ERROR]${log_title} ${NO_COLOR}$1" + fi +} + +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= -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= -f2'` + fi + echo "$OS" +} + +set_packages_and_check_cmd() +{ + case $OS in + *"debian"* | *"ubuntu"* ) + CHECK_CMD='dpkg -l | grep -w' + PACKAGES=(nfs-common open-iscsi) + ;; + *"centos"* | *"fedora"* | *"rocky"* | *"ol"* ) + CHECK_CMD='rpm -q' + PACKAGES=(nfs-utils iscsi-initiator-utils) + ;; + *"suse"* ) + CHECK_CMD='rpm -q' + PACKAGES=(nfs-client open-iscsi) + ;; + *) + CHECK_CMD='' + PACKAGES=() + warn "Stop the environment check because '$OS' is not supported in the environment check script." + exit 1 + ;; + esac +} + +check_dependencies() { local targets=($@) + local allFound=true for ((i=0; i<${#targets[@]}; i++)); do local target=${targets[$i]} if [ "$(which $target)" == "" ]; then allFound=false - echo Not found: $target + error "Not found: $target" fi done if [ "$allFound" == "false" ]; then - echo "Please install missing dependencies." + error "Please install missing dependencies." exit 2 + else + info "Required dependencies are installed." fi } @@ -33,9 +138,10 @@ spec: labels: app: longhorn-environment-check spec: + hostPID: true containers: - name: longhorn-environment-check - image: busybox + image: alpine:3.12 args: ["/bin/sh", "-c", "sleep 1000000000"] volumeMounts: - name: mountpoint @@ -48,14 +154,14 @@ spec: hostPath: path: /tmp/longhorn-environment-check EOF - kubectl create -f $TEMP_DIR/environment_check.yaml + kubectl create -f $TEMP_DIR/environment_check.yaml > /dev/null } cleanup() { - echo "cleaning up..." - kubectl delete -f $TEMP_DIR/environment_check.yaml + info "Cleaning up longhorn-environment-check pods..." + kubectl delete -f $TEMP_DIR/environment_check.yaml > /dev/null rm -rf $TEMP_DIR - echo "clean up complete" + info "Cleanup completed." } wait_ds_ready() { @@ -65,16 +171,16 @@ wait_ds_ready() { local desiredNumberScheduled=$(echo $ds | jq .status.desiredNumberScheduled) if [ "$desiredNumberScheduled" == "$numberReady" ] && [ "$desiredNumberScheduled" != "0" ]; then - echo "all pods ready ($numberReady/$desiredNumberScheduled)" + info "All longhorn-environment-check pods are ready ($numberReady/$desiredNumberScheduled)." return fi - echo "waiting for pods to become ready ($numberReady/$desiredNumberScheduled)" + info "Waiting for longhorn-environment-check pods to become ready ($numberReady/$desiredNumberScheduled)..." sleep 3 done } -validate_ds() { +check_mount_propagation() { local allSupported=true local pods=$(kubectl -l app=longhorn-environment-check get po -o json) @@ -88,25 +194,101 @@ validate_ds() { if [ "$mountPropagation" != "Bidirectional" ]; then allSupported=false - echo "node $nodeName: MountPropagation DISABLED" + error "node $nodeName: MountPropagation is disabled" fi done if [ "$allSupported" != "true" ]; then - echo - echo " MountPropagation is disabled on at least one node." - echo " As a result, CSI driver and Base image cannot be supported." - echo + error "MountPropagation is disabled on at least one node. As a result, CSI driver and Base image cannot be supported." exit 1 else - echo -e "\n MountPropagation is enabled!\n" + info "MountPropagation is enabled." fi } -dependencies kubectl jq mktemp +check_package_installed() { + local pods=$(kubectl get pods -o name | grep longhorn-environment-check) + + local allFound=true + + for pod in ${pods}; do + OS=`detect_node_os $pod` + if [ x"$OS" == x"" ]; then + error "Unable to detect OS on node $node." + exit 2 + fi + + set_packages_and_check_cmd "$OS" + + for ((i=0; i<${#PACKAGES[@]}; i++)); do + local package=${PACKAGES[$i]} + + 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` + error "$package is not found in $node." + fi + done + done + + if [ "$allFound" == "false" ]; then + error "Please install missing packages." + exit 2 + else + info "Required packages are installed." + fi +} + +check_multipathd() { + local pods=$(kubectl get pods -o name | grep longhorn-environment-check) + local allNotFound=true + + for pod in ${pods}; do + kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "systemctl status --no-pager multipathd.service" > /dev/null 2>&1 + if [ $? = 0 ]; then + allNotFound=false + node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName` + warn "multipathd is running on $node." + fi + done + + if [ "$allNotFound" == "false" ]; then + warn "multipathd would probably result in the Longhorn volume mount failure. Please refer to https://longhorn.io/kb/troubleshooting-volume-with-multipath for more information." + fi +} + +check_iscsid() { + local pods=$(kubectl get pods -o name | grep longhorn-environment-check) + local allFound=true + + for pod in ${pods}; do + kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "systemctl status --no-pager iscsid.service" > /dev/null 2>&1 + + if [ $? != 0 ]; then + allFound=false + node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName` + error "iscsid is not running on $node." + fi + done + + if [ "$allFound" == "false" ]; then + exit 2 + fi +} + +DEPENDENCIES=(kubectl jq mktemp) +check_dependencies ${DEPENDENCIES[@]} + TEMP_DIR=$(mktemp -d) + trap cleanup EXIT create_ds wait_ds_ready -validate_ds +check_package_installed +check_iscsid +check_multipathd +check_mount_propagation + exit 0 + diff --git a/uninstall/uninstall.yaml b/uninstall/uninstall.yaml index 4a1665d..52062a5 100644 --- a/uninstall/uninstall.yaml +++ b/uninstall/uninstall.yaml @@ -101,7 +101,7 @@ spec: spec: containers: - name: longhorn-uninstall - image: longhornio/longhorn-manager:v1.2.4 + image: longhornio/longhorn-manager:v1.2.5-rc1 imagePullPolicy: IfNotPresent securityContext: privileged: true