Skip to content

Commit 6880b0c

Browse files
committed
prow.sh: avoid creating paths unless really running tests
verify-go-version.sh sources prow.sh to determine the desired Go version. This had the unintended side effect of creating one $GOPATH/pkg/csiprow.* directory per make invocation and triggered error messages when GOPATH was not set. Also, `go env GOPATH` is now used as fallback when not set explicitly.
1 parent bc0504a commit 6880b0c

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

Diff for: prow.sh

+23-14
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ kindest/node:v1.14.10@sha256:3fbed72bcac108055e46e7b4091eb6858ad628ec51bf693c21f
159159
# Use kind node-image --type=bazel by default, but allow to disable that.
160160
configvar CSI_PROW_USE_BAZEL true "use Bazel during 'kind node-image' invocation"
161161

162-
# Work directory. It has to allow running executables, therefore /tmp
163-
# is avoided. Cleaning up after the script is intentionally left to
164-
# the caller.
165-
configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csiprow.XXXXXXXXXX")" "work directory"
166-
167162
# By default, this script tests sidecars with the CSI hostpath driver,
168163
# using the install_csi_driver function. That function depends on
169164
# a deployment script that it searches for in several places:
@@ -361,10 +356,23 @@ configvar CSI_SNAPSHOTTER_VERSION "$(default_csi_snapshotter_version)" "external
361356
# to all the K8s versions we test against
362357
configvar CSI_PROW_E2E_SKIP 'Disruptive|different\s+node' "tests that need to be skipped"
363358

364-
# This is the directory for additional result files. Usually set by Prow, but
365-
# if not (for example, when invoking manually) it defaults to the work directory.
366-
configvar ARTIFACTS "${CSI_PROW_WORK}/artifacts" "artifacts"
367-
mkdir -p "${ARTIFACTS}"
359+
# This creates directories that are required for testing.
360+
ensure_paths () {
361+
# Work directory. It has to allow running executables, therefore /tmp
362+
# is avoided. Cleaning up after the script is intentionally left to
363+
# the caller.
364+
configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csiprow.XXXXXXXXXX")" "work directory"
365+
366+
# This is the directory for additional result files. Usually set by Prow, but
367+
# if not (for example, when invoking manually) it defaults to the work directory.
368+
configvar ARTIFACTS "${CSI_PROW_WORK}/artifacts" "artifacts"
369+
mkdir -p "${ARTIFACTS}"
370+
371+
# For additional tools.
372+
CSI_PROW_BIN="${CSI_PROW_WORK}/bin"
373+
mkdir -p "${CSI_PROW_BIN}"
374+
PATH="${CSI_PROW_BIN}:$PATH"
375+
}
368376

369377
run () {
370378
echo "$(date) $(go version | sed -e 's/.*version \(go[^ ]*\).*/\1/') $(if [ "$(pwd)" != "${REPO_DIR}" ]; then pwd; fi)\$" "$@" >&2
@@ -384,11 +392,6 @@ die () {
384392
exit 1
385393
}
386394

387-
# For additional tools.
388-
CSI_PROW_BIN="${CSI_PROW_WORK}/bin"
389-
mkdir -p "${CSI_PROW_BIN}"
390-
PATH="${CSI_PROW_BIN}:$PATH"
391-
392395
# Ensure that PATH has the desired version of the Go tools, then run command given as argument.
393396
# Empty parameter uses the already installed Go. In Prow, that version is kept up-to-date by
394397
# bumping the container image regularly.
@@ -1098,6 +1101,9 @@ main () {
10981101
local images ret
10991102
ret=0
11001103
1104+
# Set up work directory.
1105+
ensure_paths
1106+
11011107
images=
11021108
if ${CSI_PROW_BUILD_JOB}; then
11031109
# A successful build is required for testing.
@@ -1259,6 +1265,9 @@ gcr_cloud_build () {
12591265
# Required for "docker buildx build --push".
12601266
gcloud auth configure-docker
12611267
1268+
# Might not be needed here, but call it just in case.
1269+
ensure_paths
1270+
12621271
if find . -name Dockerfile | grep -v ^./vendor | xargs --no-run-if-empty cat | grep -q ^RUN; then
12631272
# Needed for "RUN" steps on non-linux/amd64 platforms.
12641273
# See https://github.com/multiarch/qemu-user-static#getting-started

0 commit comments

Comments
 (0)