From 61538bb776c5cae63d8dc40c68e6830389774c62 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 25 May 2021 15:03:39 +0200 Subject: [PATCH] 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. --- prow.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/prow.sh b/prow.sh index 55f2a91c..ca71e27a 100755 --- a/prow.sh +++ b/prow.sh @@ -654,22 +654,30 @@ delete_cluster_inside_prow_job() { # Looks for the deployment as specified by CSI_PROW_DEPLOYMENT and CSI_PROW_KUBERNETES_VERSION # in the given directory. find_deployment () { - local dir file + local dir file k8sver dir="$1" - # Fixed deployment name? Use it if it exists, otherwise fail. + # major/minor without release- prefix. + k8sver="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/' -e 's/^release-//')" + + # Fixed deployment name? Use it if it exists. if [ "${CSI_PROW_DEPLOYMENT}" ]; then file="$dir/${CSI_PROW_DEPLOYMENT}/deploy.sh" - if ! [ -e "$file" ]; then + if [ -e "$file" ]; then + echo "$file" + return 0 + fi + + # CSI_PROW_DEPLOYMENT=kubernetes-x.yy is handled below with a fallback + # to kubernetes-latest. If it is something else, then fail here. + if ! echo "${CSI_PROW_DEPLOYMENT}" | grep -q "^kubernetes-${k8sver}\$"; then return 1 fi - echo "$file" - return 0 fi # Ignore: See if you can use ${variable//search/replace} instead. # shellcheck disable=SC2001 - file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh" + file="$dir/kubernetes-${k8sver}${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh" if ! [ -e "$file" ]; then file="$dir/kubernetes-latest${CSI_PROW_DEPLOYMENT_SUFFIX}/deploy.sh" if ! [ -e "$file" ]; then