Skip to content

Commit 741319b

Browse files
committed
prow.sh: improve building Kubernetes from source
While switching back and forth between release-1.13 and release-1.14 locally, there was the problem that the local kind image kept using the wrong kubelet binary despite rebuilding from source. The problem went away after cleaning the Bazel cache. Exact root cause unknown, but perhaps using unique tags and properly cleaning the repo helps. If not, then the unique tags at least will show what the problem is.
1 parent 29545bb commit 741319b

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

prow.sh

+17-4
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ git_checkout () {
360360
(cd "$path" && run git fetch "$repo" '+refs/heads/*:refs/remotes/csiprow/heads/*' '+refs/tags/*:refs/tags/*') || die "fetching $repo failed"
361361
(cd "$path" && run git checkout "$revision") || die "checking out $repo $revision failed"
362362
fi
363+
# This is useful for local testing or when switching between different revisions in the same
364+
# repo.
365+
(cd "$path" && run git clean -fdx) || die "failed to clean $path"
363366
}
364367

365368
list_gates () (
@@ -410,10 +413,20 @@ start_cluster () {
410413
git_checkout https://github.com/kubernetes/kubernetes "$GOPATH/src/k8s.io/kubernetes" "$version" --depth=1 || die "checking out Kubernetes $version failed"
411414

412415
# "kind build" and/or the Kubernetes build rules need at least one tag, which we don't have
413-
# when doing a shallow fetch. Therefore we fake one. For some reason, v1.0.0 didn't work
414-
# while v1.14.0-fake.1 did.
415-
(cd "$GOPATH/src/k8s.io/kubernetes" && run git tag -f v1.14.0-fake.1) || die "git tag failed"
416-
416+
# when doing a shallow fetch. Therefore we fake one:
417+
# release-1.12 -> v1.12.0-release.<rev>.csiprow
418+
# latest or <revision> -> v1.14.0-<rev>.csiprow
419+
case "${CSI_PROW_KUBERNETES_VERSION}" in
420+
release-*)
421+
# Ignore: See if you can use ${variable//search/replace} instead.
422+
# shellcheck disable=SC2001
423+
tag="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/release-\(.*\)/v\1.0-release./')";;
424+
*)
425+
# We have to make something up. v1.0.0 did not work for some reasons.
426+
tag="v1.14.0-";;
427+
esac
428+
tag="$tag$(cd "$GOPATH/src/k8s.io/kubernetes" && git rev-list --abbrev-commit HEAD).csiprow"
429+
(cd "$GOPATH/src/k8s.io/kubernetes" && run git tag -f "$tag") || die "git tag failed"
417430
go_version="$(go_version_for_kubernetes "$GOPATH/src/k8s.io/kubernetes" "$version")" || die "cannot proceed without knowing Go version for Kubernetes"
418431
run_with_go "$go_version" kind build node-image --type bazel --image csiprow/node:latest --kube-root "$GOPATH/src/k8s.io/kubernetes" || die "'kind build node-image' failed"
419432
csi_prow_kind_have_kubernetes=true

0 commit comments

Comments
 (0)