Skip to content

Commit c01c9d7

Browse files
committed
Enable the VolumeGroupSnapshot tests
Signed-off-by: Penghao <[email protected]>
1 parent 32db64f commit c01c9d7

File tree

1 file changed

+68
-5
lines changed

1 file changed

+68
-5
lines changed

release-tools/prow.sh

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
# - kind (https://github.com/kubernetes-sigs/kind) installed
3838
# - optional: Go already installed
3939

40+
set -x
41+
4042
RELEASE_TOOLS_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
4143
REPO_DIR="$(pwd)"
4244

@@ -323,7 +325,7 @@ configvar CSI_PROW_E2E_MOCK "$(if [ "${CSI_PROW_DRIVER_CANARY}" = "canary" ] &&
323325

324326
# Regex for non-alpha, feature-tagged tests that should be run.
325327
#
326-
configvar CSI_PROW_E2E_FOCUS_LATEST '\[Feature:VolumeSnapshotDataSource\]' "non-alpha, feature-tagged tests for latest Kubernetes version"
328+
configvar CSI_PROW_E2E_FOCUS_LATEST '\[Feature:VolumeSnapshotDataSource\]|\[Feature:volumegroupsnapshot\]' "non-alpha, feature-tagged tests for latest Kubernetes version"
327329
configvar CSI_PROW_E2E_FOCUS "$(get_versioned_variable CSI_PROW_E2E_FOCUS "${csi_prow_kubernetes_version_suffix}")" "non-alpha, feature-tagged tests"
328330

329331
# Serial vs. parallel is always determined by these regular expressions.
@@ -360,6 +362,10 @@ configvar CSI_PROW_E2E_ALPHA "$(get_versioned_variable CSI_PROW_E2E_ALPHA "${csi
360362
# kubernetes-csi components must be updated, either by disabling
361363
# the failing test for "latest" or by updating the test and not running
362364
# it anymore for older releases.
365+
366+
# Hack enable the vgs feature gate
367+
export CSI_PROW_E2E_GATES_1_33="CSIVolumeGroupSnapshot=true"
368+
363369
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST '' "alpha feature gates for latest Kubernetes"
364370
configvar CSI_PROW_E2E_ALPHA_GATES "$(get_versioned_variable CSI_PROW_E2E_ALPHA_GATES "${csi_prow_kubernetes_version_suffix}")" "alpha E2E feature gates"
365371

@@ -379,8 +385,12 @@ default_csi_snapshotter_version () {
379385
echo "v4.0.0"
380386
fi
381387
}
388+
export CSI_SNAPSHOTTER_HACK_VERSION="master"
382389
configvar CSI_SNAPSHOTTER_VERSION "$(default_csi_snapshotter_version)" "external-snapshotter version tag"
383390

391+
# Enable installing VolumeGroupSnapshot CRDs (off by default, can be set to true in prow jobs)
392+
configvar CSI_PROW_ENABLE_GROUP_SNAPSHOT "true" "Enable the VolumeGroupSnapshot tests"
393+
384394
# Some tests are known to be unusable in a KinD cluster. For example,
385395
# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
386396
# doesn't work. Such tests should be written in a way that they verify
@@ -772,7 +782,7 @@ install_csi_driver () {
772782
# Installs all necessary snapshotter CRDs
773783
install_snapshot_crds() {
774784
# Wait until volumesnapshot CRDs are in place.
775-
CRD_BASE_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}/client/config/crd"
785+
CRD_BASE_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION}/client/config/crd"
776786
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
777787
CRD_BASE_DIR="${REPO_DIR}/client/config/crd"
778788
fi
@@ -792,11 +802,32 @@ install_snapshot_crds() {
792802
cnt=$((cnt + 1))
793803
sleep 2
794804
done
805+
806+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
807+
echo "Installing VolumeGroupSnapshot CRDs from ${CRD_BASE_DIR}"
808+
kubectl apply -f "${CRD_BASE_DIR}/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml" --validate=false
809+
kubectl apply -f "${CRD_BASE_DIR}/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml" --validate=false
810+
kubectl apply -f "${CRD_BASE_DIR}/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml" --validate=false
811+
812+
local cnt=0
813+
until kubectl get volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io \
814+
&& kubectl get volumegroupsnapshots.groupsnapshot.storage.k8s.io \
815+
&& kubectl get volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io; do
816+
if [ $cnt -gt 30 ]; then
817+
echo >&2 "ERROR: VolumeGroupSnapshot CRDs not ready after 60s"
818+
exit 1
819+
fi
820+
echo "$(date +%H:%M:%S)" "waiting for VolumeGroupSnapshot CRDs, attempt #$cnt"
821+
cnt=$((cnt + 1))
822+
sleep 2
823+
done
824+
echo "VolumeGroupSnapshot CRDs installed and ready"
825+
fi
795826
}
796827

797828
# Install snapshot controller and associated RBAC, retrying until the pod is running.
798829
install_snapshot_controller() {
799-
CONTROLLER_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}"
830+
CONTROLLER_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_HACK_VERSION}"
800831
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
801832
CONTROLLER_DIR="${REPO_DIR}"
802833
fi
@@ -859,6 +890,14 @@ install_snapshot_controller() {
859890
line="$(echo "$nocomments" | sed -e "s;$image;${name}:${NEW_TAG};")"
860891
echo " using $line" >&2
861892
fi
893+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
894+
# inject feature gate after leader election arg
895+
if echo "$nocomments" | grep -q '^[[:space:]]*- "--leader-election=true"'; then
896+
echo "$line"
897+
echo " - \"--feature-gates=CSIVolumeGroupSnapshot=true\""
898+
continue
899+
fi
900+
fi
862901
echo "$line"
863902
done)"
864903
if ! echo "$modified" | kubectl apply -f -; then
@@ -880,8 +919,15 @@ install_snapshot_controller() {
880919
exit 1
881920
fi
882921
else
883-
echo "kubectl apply -f $SNAPSHOT_CONTROLLER_YAML"
884-
kubectl apply -f "$SNAPSHOT_CONTROLLER_YAML"
922+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
923+
echo "Deploying snapshot-controller with CSIVolumeGroupSnapshot feature gate enabled"
924+
curl -s "$SNAPSHOT_CONTROLLER_YAML" | \
925+
awk '/--leader-election=true/ {print; print " - \"--feature-gates=CSIVolumeGroupSnapshot=true\""; next}1' | \
926+
kubectl apply -f - || die "failed to deploy snapshot-controller with feature gate"
927+
else
928+
echo "kubectl apply -f $SNAPSHOT_CONTROLLER_YAML"
929+
kubectl apply -f "$SNAPSHOT_CONTROLLER_YAML"
930+
fi
885931
fi
886932
887933
cnt=0
@@ -1028,6 +1074,7 @@ run_e2e () (
10281074
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
10291075
# and to avoid the large number of "skipped" tests that we get from using
10301076
# the full Kubernetes E2E testsuite while only running a few tests.
1077+
# shellcheck disable=SC2329
10311078
move_junit () {
10321079
if ls "${ARTIFACTS}"/junit_[0-9]*.xml 2>/dev/null >/dev/null; then
10331080
mkdir -p "${ARTIFACTS}/junit/${name}" &&
@@ -1038,6 +1085,11 @@ run_e2e () (
10381085
}
10391086
trap move_junit EXIT
10401087
1088+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
1089+
yq -i '.DriverInfo.Capabilities.groupSnapshot = true' "${CSI_PROW_WORK}"/test-driver.yaml
1090+
cat "${CSI_PROW_WORK}"/test-driver.yaml
1091+
fi
1092+
10411093
if [ "${name}" == "local" ]; then
10421094
cd "${GOPATH}/src/${CSI_PROW_SIDECAR_E2E_PATH}" &&
10431095
run_with_loggers env KUBECONFIG="$KUBECONFIG" KUBE_TEST_REPO_LIST="$(if [ -e "${CSI_PROW_WORK}/e2e-repo-list" ]; then echo "${CSI_PROW_WORK}/e2e-repo-list"; fi)" ginkgo --timeout="${CSI_PROW_GINKGO_TIMEOUT}" -v "$@" "${CSI_PROW_WORK}/e2e-local.test" -- -report-dir "${ARTIFACTS}" -report-prefix local
@@ -1323,6 +1375,17 @@ main () {
13231375
if ${CSI_PROW_DRIVER_INSTALL} "$images"; then
13241376
collect_cluster_info
13251377
1378+
# Temporarily hack will handle it in e2e golang codes later
1379+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
1380+
kubectl patch sts csi-hostpathplugin -n default --type='json' -p='[{
1381+
"op": "add",
1382+
"path": "/spec/template/spec/containers/5/args/-",
1383+
"value": "--feature-gates=CSIVolumeGroupSnapshot=true"
1384+
}]'
1385+
kubectl rollout status sts/csi-hostpathplugin -n default
1386+
fi
1387+
1388+
13261389
if sanity_enabled; then
13271390
if ! run_sanity; then
13281391
ret=1

0 commit comments

Comments
 (0)