diff --git a/docs/multi-node.md b/docs/multi-node.md index 5f2b708..891db68 100644 --- a/docs/multi-node.md +++ b/docs/multi-node.md @@ -28,7 +28,7 @@ SPDKCSI image `spdkcsi/spdkcsi:canary` needs to be manually built on all Kuberne Run the one-liner below on hosts `k8s-node1` and `k8s-node2` where CSI controller and node servers will be scheduled. ```bash -k8s-node1:~$ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock golang:1.14 \ +k8s-node1:~$ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock golang:1.22 \ bash -c "apt update && apt install -y make git docker.io && \ git clone https://review.spdk.io/gerrit/spdk/spdk-csi && cd spdk-csi && make image" ``` diff --git a/pkg/util/jsonrpc.go b/pkg/util/jsonrpc.go index 4c324b7..e160a8c 100644 --- a/pkg/util/jsonrpc.go +++ b/pkg/util/jsonrpc.go @@ -183,7 +183,7 @@ func (client *rpcClient) lvStores() ([]LvStore, error) { func (client *rpcClient) createVolume(lvolName, lvsName string, sizeMiB int64) (string, error) { params := struct { LvolName string `json:"lvol_name"` - Size int64 `json:"size"` + Size int64 `json:"size_in_mib"` LvsName string `json:"lvs_name"` ClearMethod string `json:"clear_method"` ThinProvision bool `json:"thin_provision"` diff --git a/scripts/install-snapshot.sh b/scripts/install-snapshot.sh index 00a119e..518e8e2 100755 --- a/scripts/install-snapshot.sh +++ b/scripts/install-snapshot.sh @@ -78,27 +78,31 @@ function delete_snapshot_crd() { # parse the kubernetes version # v1.17.2 -> kube_version 1 -> 1 (Major) # v1.17.2 -> kube_version 2 -> 17 (Minor) +# Function to parse the Kubernetes version function kube_version() { - echo "${KUBE_VERSION}" | sed 's/^v//' | cut -d'.' -f"${1}" + echo "${KUBE_MAJOR}.${KUBE_MINOR}" } -if ! get_kube_version=$(kubectl version --short) || - [[ -z "${get_kube_version}" ]]; then +# Attempt to retrieve Kubernetes version in JSON format +if ! get_kube_version_json=$(kubectl version -o json) || + [[ -z "${get_kube_version_json}" ]]; then echo "could not get Kubernetes server version" echo "hint: check if you have specified the right host or port" exit 1 fi -KUBE_VERSION=$(echo "${get_kube_version}" | grep "^Server Version" | cut -d' ' -f3) -KUBE_MAJOR=$(kube_version 1) -KUBE_MINOR=$(kube_version 2) +# Extracting the major and minor version directly from JSON +KUBE_MAJOR=$(echo "${get_kube_version_json}" | grep '"major":' | head -1 | awk -F '"' '{print $4}') +KUBE_MINOR=$(echo "${get_kube_version_json}" | grep '"minor":' | head -1 | awk -F '"' '{print $4}') -# skip snapshot operation if kube version is less than 1.17.0 + +# Skip snapshot operation if kube version is less than 1.17.0 if [[ "${KUBE_MAJOR}" -lt 1 ]] || [[ "${KUBE_MAJOR}" -eq 1 && "${KUBE_MINOR}" -lt 17 ]]; then echo "skipping: Kubernetes server version is < 1.17.0" exit 1 fi +# Handle command-line arguments case "${1:-}" in install) install_snapshot_controller "$2" @@ -116,3 +120,4 @@ delete-crd) echo " $0 delete-crd" >&2 ;; esac +