Skip to content

Commit

Permalink
DO NOT MERGE: get kind fix for Kubernetes master image building
Browse files Browse the repository at this point in the history
  • Loading branch information
msau42 committed Aug 3, 2019
1 parent 4b2c735 commit 19d4694
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .prow.sh
Expand Up @@ -12,6 +12,8 @@ CSI_PROW_HOSTPATH_DRIVER_NAME="hostpath.csi.k8s.io"

CSI_PROW_TESTS_SANITY="sanity"

CSI_PROW_KIND_VERSION="2555d8e09d5a77ee718414cec9f6083dfa028dc5"

. release-tools/prow.sh

main
54 changes: 30 additions & 24 deletions release-tools/prow.sh
Expand Up @@ -379,8 +379,8 @@ install_kind () {
if run curl --fail --location -o "${CSI_PROW_WORK}/bin/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${CSI_PROW_KIND_VERSION}/kind-linux-amd64"; then
chmod u+x "${CSI_PROW_WORK}/bin/kind"
else
git_checkout https://github.com/kubernetes-sigs/kind "$GOPATH/src/sigs.k8s.io/kind" "${CSI_PROW_KIND_VERSION}" --depth=1 &&
run_with_go "${CSI_PROW_GO_VERSION_KIND}" go build -o "${CSI_PROW_WORK}/bin/kind" sigs.k8s.io/kind
git_checkout https://github.com/kubernetes-sigs/kind "${GOPATH}/src/sigs.k8s.io/kind" "${CSI_PROW_KIND_VERSION}" --depth=1 &&
(cd "${GOPATH}/src/sigs.k8s.io/kind && make install" INSTALL_DIR="${CSI_PROW_WORK}/bin")
fi
}

Expand Down Expand Up @@ -427,6 +427,30 @@ git_checkout () {
(cd "$path" && run git clean -fdx) || die "failed to clean $path"
}

# This clones out a repo ("https://github.com/kubernetes/kubernetes")
# in a certain location ("$GOPATH/src/k8s.io/kubernetes") at
# a certain revision (a hex commit hash, v1.13.1, master). The directory
# cannot exist.
git_clone () {
local repo path revision parent
repo="$1"
shift
path="$1"
shift
revision="$1"
shift

parent="$(dirname "$path")"
mkdir -p "$parent"
(cd "$parent" && run git clone "$repo" "$path") || die "cloning $repo" failed
if [ "$revision" != "latest" ]; then
(cd "$path" && run git reset --hard "$revision") || die "resetting $repo to $revision failed"
fi
# This is useful for local testing or when switching between different revisions in the same
# repo.
(cd "$path" && run git clean -fdx) || die "failed to clean $path"
}

list_gates () (
set -f; IFS=','
# Ignore: Double quote to prevent globbing and word splitting.
Expand Down Expand Up @@ -469,28 +493,10 @@ start_cluster () {
if [[ "${CSI_PROW_KUBERNETES_VERSION}" =~ ^release-|^latest$ ]]; then
if ! ${csi_prow_kind_have_kubernetes}; then
local version="${CSI_PROW_KUBERNETES_VERSION}"
if [ "$version" = "latest" ]; then
version=master
fi
git_checkout https://github.com/kubernetes/kubernetes "$GOPATH/src/k8s.io/kubernetes" "$version" --depth=1 || die "checking out Kubernetes $version failed"

# "kind build" and/or the Kubernetes build rules need at least one tag, which we don't have
# when doing a shallow fetch. Therefore we fake one:
# release-1.12 -> v1.12.0-release.<rev>.csiprow
# latest or <revision> -> v1.14.0-<rev>.csiprow
case "${CSI_PROW_KUBERNETES_VERSION}" in
release-*)
# Ignore: See if you can use ${variable//search/replace} instead.
# shellcheck disable=SC2001
tag="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/release-\(.*\)/v\1.0-release./')";;
*)
# We have to make something up. v1.0.0 did not work for some reasons.
tag="v999.999.999-";;
esac
tag="$tag$(cd "$GOPATH/src/k8s.io/kubernetes" && git rev-list --abbrev-commit HEAD).csiprow"
(cd "$GOPATH/src/k8s.io/kubernetes" && run git tag -f "$tag") || die "git tag failed"
go_version="$(go_version_for_kubernetes "$GOPATH/src/k8s.io/kubernetes" "$version")" || die "cannot proceed without knowing Go version for Kubernetes"
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"
git_clone https://github.com/kubernetes/kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$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"
run_with_go "$go_version" kind build node-image --type bazel --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

0 comments on commit 19d4694

Please sign in to comment.