Skip to content

Commit 61538bb

Browse files
committed
prow.sh: more flexible CSI_PROW_DEPLOYMENT
CSI_PROW_DEPLOYMENT was set explicitly for a variety of jobs. When testing an upcoming Kubernetes release, those jobs failed because an explicit CSI_PROW_DEPLOYMENT=kubernetes-1.21 was not matched to kubernetes-latest and thus failed because such a deployment usually only gets added much later. This must have been broken for a long time.
1 parent 2b0e6db commit 61538bb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Diff for: prow.sh

+14-6
Original file line numberDiff line numberDiff line change
@@ -654,22 +654,30 @@ 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
657+
local dir file k8sver
658658
dir="$1"
659659

660-
# Fixed deployment name? Use it if it exists, otherwise fail.
660+
# major/minor without release- prefix.
661+
k8sver="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/' -e 's/^release-//')"
662+
663+
# Fixed deployment name? Use it if it exists.
661664
if [ "${CSI_PROW_DEPLOYMENT}" ]; then
662665
file="$dir/${CSI_PROW_DEPLOYMENT}/deploy.sh"
663-
if ! [ -e "$file" ]; then
666+
if [ -e "$file" ]; then
667+
echo "$file"
668+
return 0
669+
fi
670+
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
664674
return 1
665675
fi
666-
echo "$file"
667-
return 0
668676
fi
669677

670678
# Ignore: See if you can use ${variable//search/replace} instead.
671679
# shellcheck disable=SC2001
672-
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh"
680+
file="$dir/kubernetes-${k8sver}${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh"
673681
if ! [ -e "$file" ]; then
674682
file="$dir/kubernetes-latest${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh"
675683
if ! [ -e "$file" ]; then

0 commit comments

Comments
 (0)