Skip to content

Commit b3f73ef

Browse files
committed
Squashed 'release-tools/' changes from 4aff857..c6a88c6
c6a88c6 Merge pull request #113 from xing-yang/install_snapshot_controller 45ec4c6 Fix the install of snapshot CRDs and controller 5d874cc Merge pull request #112 from xing-yang/cleanup 79bbca7 Cleanup d437673 Merge pull request #111 from xing-yang/update_snapshot_v1_rc 57718f8 Update snapshot CRD version git-subtree-dir: release-tools git-subtree-split: c6a88c6
1 parent 75fe9dd commit b3f73ef

File tree

1 file changed

+75
-3
lines changed

1 file changed

+75
-3
lines changed

prow.sh

+75-3
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,14 @@ configvar CSI_PROW_E2E_ALPHA_GATES_LATEST 'GenericEphemeralVolume=true,CSIStorag
330330
configvar CSI_PROW_E2E_ALPHA_GATES "$(get_versioned_variable CSI_PROW_E2E_ALPHA_GATES "${csi_prow_kubernetes_version_suffix}")" "alpha E2E feature gates"
331331

332332
# Which external-snapshotter tag to use for the snapshotter CRD and snapshot-controller deployment
333-
configvar CSI_SNAPSHOTTER_VERSION 'v3.0.0' "external-snapshotter version tag"
333+
default_csi_snapshotter_version () {
334+
if [ "${CSI_PROW_KUBERNETES_VERSION}" = "latest" ] || [ "${CSI_PROW_DRIVER_CANARY}" = "canary" ]; then
335+
echo "master"
336+
else
337+
echo "v3.0.2"
338+
fi
339+
}
340+
configvar CSI_SNAPSHOTTER_VERSION "$(default_csi_snapshotter_version)" "external-snapshotter version tag"
334341

335342
# Some tests are known to be unusable in a KinD cluster. For example,
336343
# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
@@ -693,6 +700,10 @@ install_csi_driver () {
693700
install_snapshot_crds() {
694701
# Wait until volumesnapshot CRDs are in place.
695702
CRD_BASE_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}/client/config/crd"
703+
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
704+
CRD_BASE_DIR="${REPO_DIR}/client/config/crd"
705+
fi
706+
echo "Installing snapshot CRDs from ${CRD_BASE_DIR}"
696707
kubectl apply -f "${CRD_BASE_DIR}/snapshot.storage.k8s.io_volumesnapshotclasses.yaml" --validate=false
697708
kubectl apply -f "${CRD_BASE_DIR}/snapshot.storage.k8s.io_volumesnapshots.yaml" --validate=false
698709
kubectl apply -f "${CRD_BASE_DIR}/snapshot.storage.k8s.io_volumesnapshotcontents.yaml" --validate=false
@@ -712,7 +723,16 @@ install_snapshot_crds() {
712723

713724
# Install snapshot controller and associated RBAC, retrying until the pod is running.
714725
install_snapshot_controller() {
715-
kubectl apply -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}/deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
726+
CONTROLLER_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}"
727+
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
728+
CONTROLLER_DIR="${REPO_DIR}"
729+
fi
730+
SNAPSHOT_RBAC_YAML="${CONTROLLER_DIR}/deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
731+
echo "kubectl apply -f ${SNAPSHOT_RBAC_YAML}"
732+
# Ignore: Double quote to prevent globbing and word splitting.
733+
# shellcheck disable=SC2086
734+
kubectl apply -f ${SNAPSHOT_RBAC_YAML}
735+
716736
cnt=0
717737
until kubectl get clusterrolebinding snapshot-controller-role; do
718738
if [ $cnt -gt 30 ]; then
@@ -726,8 +746,60 @@ install_snapshot_controller() {
726746
sleep 10
727747
done
728748

749+
SNAPSHOT_CONTROLLER_YAML="${CONTROLLER_DIR}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
750+
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
751+
# snapshot-controller image built from the PR will get a "csiprow" tag.
752+
# Load it into the "kind" cluster so that we can deploy it.
753+
NEW_TAG="csiprow"
754+
NEW_IMG="snapshot-controller:${NEW_TAG}"
755+
echo "kind load docker-image --name csi-prow ${NEW_IMG}"
756+
kind load docker-image --name csi-prow ${NEW_IMG} || die "could not load the snapshot-controller:csiprow image into the kind cluster"
757+
758+
# deploy snapshot-controller
759+
echo "Deploying snapshot-controller"
760+
# Replace image in SNAPSHOT_CONTROLLER_YAML with snapshot-controller:csiprow and deploy
761+
# NOTE: This logic is similar to the logic here:
762+
# https://github.com/kubernetes-csi/csi-driver-host-path/blob/v1.4.0/deploy/util/deploy-hostpath.sh#L155
763+
# Ignore: Double quote to prevent globbing and word splitting.
764+
# shellcheck disable=SC2086
765+
# Ignore: Use find instead of ls to better handle non-alphanumeric filenames.
766+
# shellcheck disable=SC2012
767+
for i in $(ls ${SNAPSHOT_CONTROLLER_YAML} | sort); do
768+
echo " $i"
769+
# Ignore: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
770+
# shellcheck disable=SC2002
771+
# Ignore: See if you can use ${variable//search/replace} instead.
772+
# shellcheck disable=SC2001
773+
modified="$(cat "$i" | while IFS= read -r line; do
774+
nocomments="$(echo "$line" | sed -e 's/ *#.*$//')"
775+
if echo "$nocomments" | grep -q '^[[:space:]]*image:[[:space:]]*'; then
776+
# Split 'image: k8s.gcr.io/sig-storage/snapshot-controller:v3.0.0'
777+
# into image (snapshot-controller:v3.0.0),
778+
# name (snapshot-controller),
779+
# tag (v3.0.0).
780+
image=$(echo "$nocomments" | sed -e 's;.*image:[[:space:]]*;;')
781+
name=$(echo "$image" | sed -e 's;.*/\([^:]*\).*;\1;')
782+
tag=$(echo "$image" | sed -e 's;.*:;;')
783+
784+
# Now replace registry and/or tag
785+
NEW_TAG="csiprow"
786+
line="$(echo "$nocomments" | sed -e "s;$image;${name}:${NEW_TAG};")"
787+
echo " using $line" >&2
788+
fi
789+
echo "$line"
790+
done)"
791+
if ! echo "$modified" | kubectl apply -f -; then
792+
echo "modified version of $i:"
793+
echo "$modified"
794+
exit 1
795+
fi
796+
echo "kubectl apply -f ${SNAPSHOT_CONTROLLER_YAML}(modified)"
797+
done
798+
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"
801+
fi
729802
730-
kubectl apply -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
731803
cnt=0
732804
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-)
733805
while [ "$(kubectl get pods -l app=snapshot-controller | grep 'Running' -c)" -lt "$expected_running_pods" ]; do

0 commit comments

Comments
 (0)