Skip to content

Commit 366ad72

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

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

pkg/features/features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ func init() {
3939
// defaultKubernetesFeatureGates consists of all known feature keys specific to external-snapshotter.
4040
// To add a new feature, define a key for it above and add it here.
4141
var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
42-
VolumeGroupSnapshot: {Default: false, PreRelease: featuregate.Beta},
42+
VolumeGroupSnapshot: {Default: true, PreRelease: featuregate.Beta},
4343
ReleaseLeaderElectionOnExit: {Default: false, PreRelease: featuregate.Alpha},
4444
}

release-tools/prow.sh

Lines changed: 55 additions & 2 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

@@ -381,6 +383,9 @@ default_csi_snapshotter_version () {
381383
}
382384
configvar CSI_SNAPSHOTTER_VERSION "$(default_csi_snapshotter_version)" "external-snapshotter version tag"
383385

386+
# Enable installing VolumeGroupSnapshot CRDs (off by default, can be set to true in prow jobs)
387+
configvar CSI_PROW_ENABLE_GROUP_SNAPSHOT "true" "Enable the VolumeGroupSnapshot tests"
388+
384389
# Some tests are known to be unusable in a KinD cluster. For example,
385390
# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
386391
# doesn't work. Such tests should be written in a way that they verify
@@ -794,6 +799,37 @@ install_snapshot_crds() {
794799
done
795800
}
796801

802+
# Installs VolumeGroupSnapshot CRDs (VolumeGroupSnapshot, VolumeGroupSnapshotContent, VolumeGroupSnapshotClass)
803+
install_volumegroupsnapshot_crds() {
804+
local crd_base_dir="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}/client/config/crd"
805+
806+
# If we are running inside the external-snapshotter repo, use local files instead of GitHub
807+
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
808+
crd_base_dir="${REPO_DIR}/client/config/crd"
809+
fi
810+
811+
echo "Installing VolumeGroupSnapshot CRDs from ${crd_base_dir}"
812+
kubectl apply -f "${crd_base_dir}/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml" --validate=false
813+
kubectl apply -f "${crd_base_dir}/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml" --validate=false
814+
kubectl apply -f "${crd_base_dir}/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml" --validate=false
815+
816+
local cnt=0
817+
until kubectl get volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io \
818+
&& kubectl get volumegroupsnapshots.groupsnapshot.storage.k8s.io \
819+
&& kubectl get volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io; do
820+
if [ $cnt -gt 30 ]; then
821+
echo >&2 "ERROR: VolumeGroupSnapshot CRDs not ready after 60s"
822+
exit 1
823+
fi
824+
echo "$(date +%H:%M:%S)" "waiting for VolumeGroupSnapshot CRDs, attempt #$cnt"
825+
cnt=$((cnt + 1))
826+
sleep 2
827+
done
828+
829+
echo "VolumeGroupSnapshot CRDs installed and ready"
830+
}
831+
832+
797833
# Install snapshot controller and associated RBAC, retrying until the pod is running.
798834
install_snapshot_controller() {
799835
CONTROLLER_DIR="https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}"
@@ -880,8 +916,15 @@ install_snapshot_controller() {
880916
exit 1
881917
fi
882918
else
883-
echo "kubectl apply -f $SNAPSHOT_CONTROLLER_YAML"
884-
kubectl apply -f "$SNAPSHOT_CONTROLLER_YAML"
919+
if [ "${CSI_PROW_ENABLE_GROUP_SNAPSHOT}" = "true" ]; then
920+
echo "Deploying snapshot-controller with CSIVolumeGroupSnapshot feature gate enabled"
921+
curl -s "$SNAPSHOT_CONTROLLER_YAML" | \
922+
awk '/--leader-election=true/ {print; print " - \"--feature-gates=CSIVolumeGroupSnapshot=true\""; next}1' | \
923+
kubectl apply -f - || die "failed to deploy snapshot-controller with feature gate"
924+
else
925+
echo "kubectl apply -f $SNAPSHOT_CONTROLLER_YAML"
926+
kubectl apply -f "$SNAPSHOT_CONTROLLER_YAML"
927+
fi
885928
fi
886929
887930
cnt=0
@@ -1038,6 +1081,10 @@ run_e2e () (
10381081
}
10391082
trap move_junit EXIT
10401083
1084+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
1085+
sed -i '/Capabilities:/a\ groupSnapshot: true' "${CSI_PROW_WORK}/test-driver.yaml"
1086+
fi
1087+
10411088
if [ "${name}" == "local" ]; then
10421089
cd "${GOPATH}/src/${CSI_PROW_SIDECAR_E2E_PATH}" &&
10431090
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
@@ -1383,6 +1430,12 @@ main () {
13831430
install_snapshot_crds
13841431
install_snapshot_controller
13851432
1433+
# TODO: Remove the condition after the vgs GA
1434+
if ${CSI_PROW_ENABLE_GROUP_SNAPSHOT}; then
1435+
install_volumegroupsnapshot_crds
1436+
fi
1437+
1438+
13861439
# Installing the driver might be disabled.
13871440
if ${CSI_PROW_DRIVER_INSTALL} "$images"; then
13881441
collect_cluster_info

0 commit comments

Comments
 (0)