Skip to content

Commit

Permalink
e2e: defend on kube version for snap-controller install
Browse files Browse the repository at this point in the history
Currently the scripts/install-snapshot.sh script needs to be called
depending on the Kubernetes version. It would be much easier to use the
script if it is intelligent enough to decide itself whether kube snapshot
controller needs to be installed or not.

Partially Fixes: #1139
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
  • Loading branch information
Prasanna Kumar Kalever committed Sep 28, 2020
1 parent b5d1edd commit d7802eb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/install-snapshot.sh
Expand Up @@ -77,6 +77,29 @@ function delete_snapshot_crd() {
kubectl delete -f "${VOLUME_SNAPSHOT}" --ignore-not-found
}

# parse the kubernetes version
# v1.17.2 -> kube_version 1 -> 1 (Major)
# v1.17.2 -> kube_version 2 -> 17 (Minor)
function kube_version() {
echo "${KUBE_VERSION}" | sed 's/^v//' | cut -d'.' -f"${1}"
}

KUBE_VERSION=$(kubectl version --short 2>/dev/null | grep "^Server Version" | cut -d' ' -f3)
if [[ -z ${KUBE_VERSION} ]]; then
echo "could not get kube server version"
echo "hint: check if you have specified the right host or port"
exit 1
fi

KUBE_MAJOR=$(kube_version 1)
KUBE_MINOR=$(kube_version 2)

# skip snapshot operation if kube version is less than 1.17.0
if [[ "${KUBE_MAJOR}" -lt 1 ]] || [[ "${KUBE_MINOR}" -lt 17 ]]; then
echo "skipping: kube server version is < 1.17.0"
exit 1
fi

case "${1:-}" in
install)
install_snapshot_controller "$2"
Expand Down

0 comments on commit d7802eb

Please sign in to comment.