Skip to content

Commit 7ca2890

Browse files
committed
Squashed 'release-tools/' changes from 9289fd1..1d60e77
1d60e77 Merge pull request kubernetes-csi#131 from pohly/kubernetes-1.20-tag 9f10459 prow.sh: support building Kubernetes for a specific version fe1f284 Merge pull request kubernetes-csi#121 from kvaps/namespace-check 8fdf0f7 Merge pull request kubernetes-csi#128 from fengzixu/master 1c94220 fix: fix a bug of csi-sanity a4c41e6 Merge pull request kubernetes-csi#127 from pohly/fix-boilerplate ece0f50 check namespace for snapshot-controller dbd8967 verify-boilerplate.sh: fix path to script git-subtree-dir: release-tools git-subtree-split: 1d60e77
1 parent 5b7c450 commit 7ca2890

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

prow.sh

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ get_versioned_variable () {
6565
echo "$value"
6666
}
6767

68+
# This takes a version string like CSI_PROW_KUBERNETES_VERSION and
69+
# maps it to the corresponding git tag, branch or commit.
70+
version_to_git () {
71+
version="$1"
72+
shift
73+
case "$version" in
74+
latest) echo "master";;
75+
release-*) echo "$version";;
76+
*) echo "v$version";;
77+
esac
78+
}
79+
6880
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x; linux arm64 -arm64" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
6981

7082
# If we have a vendor directory, then use it. We must be careful to only
@@ -208,16 +220,7 @@ configvar CSI_PROW_DRIVER_CANARY_REGISTRY "gcr.io/k8s-staging-sig-storage" "regi
208220
# all generated files are present.
209221
#
210222
# CSI_PROW_E2E_REPO=none disables E2E testing.
211-
tag_from_version () {
212-
version="$1"
213-
shift
214-
case "$version" in
215-
latest) echo "master";;
216-
release-*) echo "$version";;
217-
*) echo "v$version";;
218-
esac
219-
}
220-
configvar CSI_PROW_E2E_VERSION "$(tag_from_version "${CSI_PROW_KUBERNETES_VERSION}")" "E2E version"
223+
configvar CSI_PROW_E2E_VERSION "$(version_to_git "${CSI_PROW_KUBERNETES_VERSION}")" "E2E version"
221224
configvar CSI_PROW_E2E_REPO "https://github.com/kubernetes/kubernetes" "E2E repo"
222225
configvar CSI_PROW_E2E_IMPORT_PATH "k8s.io/kubernetes" "E2E package"
223226

@@ -228,7 +231,7 @@ configvar CSI_PROW_E2E_IMPORT_PATH "k8s.io/kubernetes" "E2E package"
228231
# and install it inside the cluster, which is not necessarily easier.
229232
configvar CSI_PROW_SANITY_REPO https://github.com/kubernetes-csi/csi-test "csi-test repo"
230233
configvar CSI_PROW_SANITY_VERSION v4.0.2 "csi-test version" # v4.0.2
231-
configvar CSI_PROW_SANITY_IMPORT_PATH github.com/kubernetes-csi/csi-test/v4 "csi-test package"
234+
configvar CSI_PROW_SANITY_PACKAGE_PATH github.com/kubernetes-csi/csi-test "csi-test package"
232235
configvar CSI_PROW_SANITY_SERVICE "hostpath-service" "Kubernetes TCP service name that exposes csi.sock"
233236
configvar CSI_PROW_SANITY_POD "csi-hostpathplugin-0" "Kubernetes pod with CSI driver"
234237
configvar CSI_PROW_SANITY_CONTAINER "hostpath" "Kubernetes container with CSI driver"
@@ -465,20 +468,22 @@ git_checkout () {
465468

466469
# This clones a repo ("https://github.com/kubernetes/kubernetes")
467470
# in a certain location ("$GOPATH/src/k8s.io/kubernetes") at
468-
# a the head of a specific branch (i.e., release-1.13, master).
469-
# The directory cannot exist.
470-
git_clone_branch () {
471-
local repo path branch parent
471+
# a the head of a specific branch (i.e., release-1.13, master),
472+
# tag (v1.20.0) or commit.
473+
#
474+
# The directory must not exist.
475+
git_clone () {
476+
local repo path name parent
472477
repo="$1"
473478
shift
474479
path="$1"
475480
shift
476-
branch="$1"
481+
name="$1"
477482
shift
478483

479484
parent="$(dirname "$path")"
480485
mkdir -p "$parent"
481-
(cd "$parent" && run git clone --single-branch --branch "$branch" "$repo" "$path") || die "cloning $repo" failed
486+
(cd "$parent" && run git clone --single-branch --branch "$name" "$repo" "$path") || die "cloning $repo" failed
482487
# This is useful for local testing or when switching between different revisions in the same
483488
# repo.
484489
(cd "$path" && run git clean -fdx) || die "failed to clean $path"
@@ -567,7 +572,7 @@ start_cluster () {
567572
else
568573
type="docker"
569574
fi
570-
git_clone_branch https://github.com/kubernetes/kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$version" || die "checking out Kubernetes $version failed"
575+
git_clone https://github.com/kubernetes/kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$(version_to_git "$version")" || die "checking out Kubernetes $version failed"
571576

572577
go_version="$(go_version_for_kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$version")" || die "cannot proceed without knowing Go version for Kubernetes"
573578
# Changing into the Kubernetes source code directory is a workaround for https://github.com/kubernetes-sigs/kind/issues/1910
@@ -796,16 +801,17 @@ install_snapshot_controller() {
796801
echo "kubectl apply -f ${SNAPSHOT_CONTROLLER_YAML}(modified)"
797802
done
798803
else
799-
echo "kubectl apply -f ${CONTROLLER_DIR}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
800-
kubectl apply -f "${CONTROLLER_DIR}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
804+
echo "kubectl apply -f $SNAPSHOT_CONTROLLER_YAML"
805+
kubectl apply -f "$SNAPSHOT_CONTROLLER_YAML"
801806
fi
802807
803808
cnt=0
804-
expected_running_pods=$(curl https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/"${CSI_SNAPSHOTTER_VERSION}"/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml | grep replicas | cut -d ':' -f 2-)
805-
while [ "$(kubectl get pods -l app=snapshot-controller | grep 'Running' -c)" -lt "$expected_running_pods" ]; do
809+
expected_running_pods=$(kubectl apply --dry-run=client -o "jsonpath={.spec.replicas}" -f "$SNAPSHOT_CONTROLLER_YAML")
810+
expected_namespace=$(kubectl apply --dry-run=client -o "jsonpath={.metadata.namespace}" -f "$SNAPSHOT_CONTROLLER_YAML")
811+
while [ "$(kubectl get pods -n "$expected_namespace" -l app=snapshot-controller | grep 'Running' -c)" -lt "$expected_running_pods" ]; do
806812
if [ $cnt -gt 30 ]; then
807813
echo "snapshot-controller pod status:"
808-
kubectl describe pods -l app=snapshot-controller
814+
kubectl describe pods -n "$expected_namespace" -l app=snapshot-controller
809815
echo >&2 "ERROR: snapshot controller not ready after over 5 min"
810816
exit 1
811817
fi
@@ -879,8 +885,8 @@ install_sanity () (
879885
return
880886
fi
881887
882-
git_checkout "${CSI_PROW_SANITY_REPO}" "${GOPATH}/src/${CSI_PROW_SANITY_IMPORT_PATH}" "${CSI_PROW_SANITY_VERSION}" --depth=1 || die "checking out csi-sanity failed"
883-
run_with_go "${CSI_PROW_GO_VERSION_SANITY}" go test -c -o "${CSI_PROW_WORK}/csi-sanity" "${CSI_PROW_SANITY_IMPORT_PATH}/cmd/csi-sanity" || die "building csi-sanity failed"
888+
git_checkout "${CSI_PROW_SANITY_REPO}" "${GOPATH}/src/${CSI_PROW_SANITY_PACKAGE_PATH}" "${CSI_PROW_SANITY_VERSION}" --depth=1 || die "checking out csi-sanity failed"
889+
( cd "${GOPATH}/src/${CSI_PROW_SANITY_PACKAGE_PATH}/cmd/csi-sanity" && run_with_go "${CSI_PROW_GO_VERSION_SANITY}" go build -o "${CSI_PROW_WORK}/csi-sanity" ) || die "building csi-sanity failed"
884890
)
885891
886892
# Captures pod output while running some other command.

verify-boilerplate.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ TOOLS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
3131
# Directory to check. Default is the parent of the tools themselves.
3232
ROOT="${1:-${TOOLS}/..}"
3333

34-
boilerDir="${ROOT}/boilerplate"
35-
boiler="${boilerDir}/boilerplate.py"
34+
boiler="${TOOLS}/boilerplate/boilerplate.py"
3635

3736
mapfile -t files_need_boilerplate < <("${boiler}" --rootdir="${ROOT}" --verbose)
3837

0 commit comments

Comments
 (0)