Skip to content

Commit

Permalink
Squashed 'release-tools/' changes from 71c810ab..682c686a
Browse files Browse the repository at this point in the history
kubernetes-csi/csi-release-tools@682c686a Merge kubernetes-csi/csi-release-tools#162 from pohly/pod-name-via-shell-command
kubernetes-csi/csi-release-tools@36a29f5c Merge kubernetes-csi/csi-release-tools#163 from pohly/remove-bazel
kubernetes-csi/csi-release-tools@68e43ca7 prow.sh: remove Bazel build support
kubernetes-csi/csi-release-tools@c5f59c5a prow.sh: allow shell commands in CSI_PROW_SANITY_POD

git-subtree-dir: release-tools
git-subtree-split: 682c686aeb78b5390c945d7b8feb6c927cc1feff
  • Loading branch information
pohly committed May 28, 2021
1 parent 531407d commit c766e77
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
# The expected environment is:
# - $GOPATH/src/<import path> for the repository that is to be tested,
# with PR branch merged (when testing a PR)
# - optional: bazel installed (when testing against Kubernetes master),
# must be recent enough for Kubernetes master
# - running on linux-amd64
# - kind (https://github.com/kubernetes-sigs/kind) installed
# - optional: Go already installed
Expand Down Expand Up @@ -160,9 +158,6 @@ kindest/node:v1.16.15@sha256:430c03034cd856c1f1415d3e37faf35a3ea9c5aaa2812117b79
kindest/node:v1.15.12@sha256:8d575f056493c7778935dd855ded0e95c48cb2fab90825792e8fc9af61536bf9
kindest/node:v1.14.10@sha256:6033e04bcfca7c5f2a9c4ce77551e1abf385bcd2709932ec2f6a9c8c0aff6d4f" "kind images"

# Use kind node-image --type=bazel by default, but allow to disable that.
configvar CSI_PROW_USE_BAZEL true "use Bazel during 'kind node-image' invocation"

# By default, this script tests sidecars with the CSI hostpath driver,
# using the install_csi_driver function. That function depends on
# a deployment script that it searches for in several places:
Expand Down Expand Up @@ -591,17 +586,12 @@ start_cluster () {
if [ "$version" = "latest" ]; then
version=master
fi
if ${CSI_PROW_USE_BAZEL}; then
type="bazel"
else
type="docker"
fi
git_clone https://github.com/kubernetes/kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$(version_to_git "$version")" || die "checking out Kubernetes $version failed"

go_version="$(go_version_for_kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$version")" || die "cannot proceed without knowing Go version for Kubernetes"
# Changing into the Kubernetes source code directory is a workaround for https://github.com/kubernetes-sigs/kind/issues/1910
# shellcheck disable=SC2046
(cd "${CSI_PROW_WORK}/src/kubernetes" && run_with_go "$go_version" kind build node-image --image csiprow/node:latest $(if [ "$CSI_PROW_KIND_VERSION" != "main" ]; then echo --type="$type"; fi) --kube-root "${CSI_PROW_WORK}/src/kubernetes") || die "'kind build node-image' failed"
(cd "${CSI_PROW_WORK}/src/kubernetes" && run_with_go "$go_version" kind build node-image --image csiprow/node:latest --kube-root "${CSI_PROW_WORK}/src/kubernetes") || die "'kind build node-image' failed"
csi_prow_kind_have_kubernetes=true
fi
image="csiprow/node:latest"
Expand Down Expand Up @@ -996,9 +986,17 @@ run_e2e () (
run_sanity () (
install_sanity || die "installing csi-sanity failed"
if [[ "${CSI_PROW_SANITY_POD}" =~ " " ]]; then
# Contains spaces, more complex than a simple pod name.
# Evaluate as a shell command.
pod=$(eval "${CSI_PROW_SANITY_POD}") || die "evaluation failed: CSI_PROW_SANITY_POD=${CSI_PROW_SANITY_POD}"
else
pod="${CSI_PROW_SANITY_POD}"
fi
cat >"${CSI_PROW_WORK}/mkdir_in_pod.sh" <<EOF
#!/bin/sh
kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- mkdir "\$@" && echo "\$@"
kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- mkdir "\$@" && echo "\$@"
EOF
# Using "rm -rf" as fallback for "rmdir" is a workaround for:
# Node Service
Expand All @@ -1023,8 +1021,8 @@ EOF
# why it happened.
cat >"${CSI_PROW_WORK}/rmdir_in_pod.sh" <<EOF
#!/bin/sh
if ! kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- rmdir "\$@"; then
kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- rm -rf "\$@"
if ! kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- rmdir "\$@"; then
kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- rm -rf "\$@"
exit 1
fi
EOF
Expand All @@ -1043,7 +1041,7 @@ else
fi
SCRIPT
)
kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- /bin/sh -c "\${CHECK_PATH}"
kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- /bin/sh -c "\${CHECK_PATH}"
EOF
chmod u+x "${CSI_PROW_WORK}"/*dir_in_pod.sh
Expand Down

0 comments on commit c766e77

Please sign in to comment.