Skip to content

Commit ef8bd33

Browse files
committed
prow.sh: more flexible CSI_PROW_DEPLOYMENT, part II
Commit 61538bb worked for some jobs, but not for all, for example not for CSI_PROW_KUBERNETES_VERSION=latest CSI_PROW_DEPLOYMENT=kubernetes-1.21 The approach taken now is to have one code path for all file checks regardless whether CSI_PROW_DEPLOYMENT is set or not. The first version number in the deployment name gets replaced with "latest" for the fallback.
1 parent 61538bb commit ef8bd33

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

prow.sh

+18-12
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,18 @@ delete_cluster_inside_prow_job() {
654654
# Looks for the deployment as specified by CSI_PROW_DEPLOYMENT and CSI_PROW_KUBERNETES_VERSION
655655
# in the given directory.
656656
find_deployment () {
657-
local dir file k8sver
658-
dir="$1"
657+
local dir="$1"
658+
local file
659659

660660
# major/minor without release- prefix.
661-
k8sver="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/' -e 's/^release-//')"
661+
local k8sver
662+
# Ignore: See if you can use ${variable//search/replace} instead.
663+
# shellcheck disable=SC2001
664+
k8sver="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/^release-//' -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')"
665+
666+
# Desired deployment, either specified completely, including version, or derived from other variables.
667+
local deployment
668+
deployment=${CSI_PROW_DEPLOYMENT:-kubernetes-${k8sver}${CSI_PROW_DEPLOYMENT_SUFFIX}}
662669

663670
# Fixed deployment name? Use it if it exists.
664671
if [ "${CSI_PROW_DEPLOYMENT}" ]; then
@@ -668,18 +675,17 @@ find_deployment () {
668675
return 0
669676
fi
670677

671-
# CSI_PROW_DEPLOYMENT=kubernetes-x.yy is handled below with a fallback
672-
# to kubernetes-latest. If it is something else, then fail here.
673-
if ! echo "${CSI_PROW_DEPLOYMENT}" | grep -q "^kubernetes-${k8sver}\$"; then
674-
return 1
675-
fi
678+
# CSI_PROW_DEPLOYMENT=kubernetes-x.yy must be mapped to kubernetes-latest
679+
# as fallback. Same for kubernetes-distributed-x.yy.
676680
fi
677681

678-
# Ignore: See if you can use ${variable//search/replace} instead.
679-
# shellcheck disable=SC2001
680-
file="$dir/kubernetes-${k8sver}${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh"
682+
file="$dir/${deployment}/deploy.sh"
681683
if ! [ -e "$file" ]; then
682-
file="$dir/kubernetes-latest${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh"
684+
# Replace the first xx.yy number with "latest", for example
685+
# kubernetes-1.21-test -> kubernetes-latest-test.
686+
# Ignore: See if you can use ${variable//search/replace} instead.
687+
# shellcheck disable=SC2001
688+
file="$dir/$(echo "$deployment" | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*/latest/')/deploy.sh"
683689
if ! [ -e "$file" ]; then
684690
return 1
685691
fi

0 commit comments

Comments
 (0)