Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 84f78b1

Browse files
committed
prow.sh: generic driver installation
This relies on a slightly different deployment script: a "deploy.sh" must exist which knows that it has to dump a test driver configurion into the file pointed to with CSI_PROW_TEST_DRIVER, if that env variable is set. That way, we no longer need to know what capabilities the installed driver has.
1 parent 3c34b4f commit 84f78b1

File tree

1 file changed

+43
-61
lines changed

1 file changed

+43
-61
lines changed

Diff for: prow.sh

+43-61
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,21 @@ csi_prow_kubernetes_version_suffix="$(echo "${CSI_PROW_KUBERNETES_VERSION}" | tr
157157
# the caller.
158158
configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csiprow.XXXXXXXXXX")" "work directory"
159159

160-
# The hostpath deployment script is searched for in several places.
160+
# By default, this script tests sidecars with the CSI hostpath driver,
161+
# using the install_csi_driver function. That function depends on
162+
# a deployment script that it searches for in several places:
161163
#
162164
# - The "deploy" directory in the current repository: this is useful
163165
# for the situation that a component becomes incompatible with the
164166
# shared deployment, because then it can (temporarily!) provide its
165167
# own example until the shared one can be updated; it's also how
166168
# csi-driver-host-path itself provides the example.
167169
#
168-
# - CSI_PROW_HOSTPATH_VERSION of the CSI_PROW_HOSTPATH_REPO is checked
170+
# - CSI_PROW_DRIVER_VERSION of the CSI_PROW_DRIVER_REPO is checked
169171
# out: this allows other repos to reference a version of the example
170172
# that is known to be compatible.
171173
#
172-
# - The csi-driver-host-path/deploy directory has multiple sub-directories,
174+
# - The <driver repo>/deploy directory can have multiple sub-directories,
173175
# each with different deployments (stable set of images for Kubernetes 1.13,
174176
# stable set of images for Kubernetes 1.14, canary for latest Kubernetes, etc.).
175177
# This is necessary because there may be incompatible changes in the
@@ -186,16 +188,26 @@ configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csip
186188
# "none" disables the deployment of the hostpath driver.
187189
#
188190
# When no deploy script is found (nothing in `deploy` directory,
189-
# CSI_PROW_HOSTPATH_REPO=none), nothing gets deployed.
190-
configvar CSI_PROW_HOSTPATH_VERSION "v1.3.0-rc3" "hostpath driver"
191-
configvar CSI_PROW_HOSTPATH_REPO https://github.com/kubernetes-csi/csi-driver-host-path "hostpath repo"
191+
# CSI_PROW_DRIVER_REPO=none), nothing gets deployed.
192+
#
193+
# If the deployment script is called with CSI_PROW_TEST_DRIVER=<file name> as
194+
# environment variable, then it must write a suitable test driver configuration
195+
# into that file in addition to installing the driver.
196+
configvar CSI_PROW_DRIVER_VERSION "v1.3.0-rc4" "CSI driver version"
197+
configvar CSI_PROW_DRIVER_REPO https://github.com/kubernetes-csi/csi-driver-host-path "CSI driver repo"
192198
configvar CSI_PROW_DEPLOYMENT "" "deployment"
193-
configvar CSI_PROW_HOSTPATH_DRIVER_NAME "hostpath.csi.k8s.io" "the hostpath driver name"
194199

195-
# If CSI_PROW_HOSTPATH_CANARY is set (typically to "canary", but also
196-
# "1.0-canary"), then all image versions are replaced with that
197-
# version tag.
198-
configvar CSI_PROW_HOSTPATH_CANARY "" "hostpath image"
200+
# The install_csi_driver function may work also for other CSI drivers,
201+
# as long as they follow the conventions of the CSI hostpath driver.
202+
# If they don't, then a different install function can be provided in
203+
# a .prow.sh file and this config variable can be overridden.
204+
configvar CSI_PROW_DRIVER_INSTALL "install_csi_driver" "name of the shell function which installs the CSI driver"
205+
206+
# If CSI_PROW_DRIVER_CANARY is set (typically to "canary", but also
207+
# version tag. Usually empty. CSI_PROW_HOSTPATH_CANARY is
208+
# accepted as alternative name because some test-infra jobs
209+
# still use that name.
210+
configvar CSI_PROW_DRIVER_CANARY "${CSI_PROW_HOSTPATH_CANARY}" "driver image override for canary images"
199211

200212
# The E2E testing can come from an arbitrary repo. The expectation is that
201213
# the repo supports "go test ./test/e2e -args --storage.testdriver" (https://github.com/kubernetes/kubernetes/pull/72836)
@@ -613,7 +625,7 @@ find_deployment () {
613625

614626
# Fixed deployment name? Use it if it exists, otherwise fail.
615627
if [ "${CSI_PROW_DEPLOYMENT}" ]; then
616-
file="$dir/${CSI_PROW_DEPLOYMENT}/deploy-hostpath.sh"
628+
file="$dir/${CSI_PROW_DEPLOYMENT}/deploy.sh"
617629
if ! [ -e "$file" ]; then
618630
return 1
619631
fi
@@ -623,22 +635,21 @@ find_deployment () {
623635

624636
# Ignore: See if you can use ${variable//search/replace} instead.
625637
# shellcheck disable=SC2001
626-
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/deploy-hostpath.sh"
638+
file="$dir/kubernetes-$(echo "${CSI_PROW_KUBERNETES_VERSION}" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/deploy.sh"
627639
if ! [ -e "$file" ]; then
628-
file="$dir/kubernetes-latest/deploy-hostpath.sh"
640+
file="$dir/kubernetes-latest/deploy.sh"
629641
if ! [ -e "$file" ]; then
630642
return 1
631643
fi
632644
fi
633645
echo "$file"
634646
}
635647

636-
# This installs the hostpath driver example. CSI_PROW_HOSTPATH_CANARY overrides all
637-
# image versions with that canary version. The parameters of install_hostpath can be
638-
# used to override registry and/or tag of individual images (CSI_PROVISIONER_REGISTRY=localhost:9000
639-
# CSI_PROVISIONER_TAG=latest).
640-
install_hostpath () {
641-
local images deploy_hostpath
648+
# This installs the CSI driver. It's called with a list of env variables
649+
# that override the default images. CSI_PROW_DRIVER_CANARY overrides all
650+
# image versions with that canary version.
651+
install_csi_driver () {
652+
local images deploy_driver
642653
images="$*"
643654

644655
if [ "${CSI_PROW_DEPLOYMENT}" = "none" ]; then
@@ -654,31 +665,31 @@ install_hostpath () {
654665
done
655666
fi
656667

657-
if deploy_hostpath="$(find_deployment "$(pwd)/deploy")"; then
668+
if deploy_driver="$(find_deployment "$(pwd)/deploy")"; then
658669
:
659-
elif [ "${CSI_PROW_HOSTPATH_REPO}" = "none" ]; then
670+
elif [ "${CSI_PROW_DRIVER_REPO}" = "none" ]; then
660671
return 1
661672
else
662-
git_checkout "${CSI_PROW_HOSTPATH_REPO}" "${CSI_PROW_WORK}/hostpath" "${CSI_PROW_HOSTPATH_VERSION}" --depth=1 || die "checking out hostpath repo failed"
663-
if deploy_hostpath="$(find_deployment "${CSI_PROW_WORK}/hostpath/deploy")"; then
673+
git_checkout "${CSI_PROW_DRIVER_REPO}" "${CSI_PROW_WORK}/csi-driver" "${CSI_PROW_DRIVER_VERSION}" --depth=1 || die "checking out CSI driver repo failed"
674+
if deploy_driver="$(find_deployment "${CSI_PROW_WORK}/csi-driver/deploy")"; then
664675
:
665676
else
666-
die "deploy-hostpath.sh not found in ${CSI_PROW_HOSTPATH_REPO} ${CSI_PROW_HOSTPATH_VERSION}. To disable E2E testing, set CSI_PROW_HOSTPATH_REPO=none"
677+
die "deploy.sh not found in ${CSI_PROW_DRIVER_REPO} ${CSI_PROW_DRIVER_VERSION}. To disable E2E testing, set CSI_PROW_DRIVER_REPO=none"
667678
fi
668679
fi
669680

670-
if [ "${CSI_PROW_HOSTPATH_CANARY}" != "stable" ]; then
671-
images="$images IMAGE_TAG=${CSI_PROW_HOSTPATH_CANARY}"
681+
if [ "${CSI_PROW_DRIVER_CANARY}" != "stable" ]; then
682+
images="$images IMAGE_TAG=${CSI_PROW_DRIVER_CANARY}"
672683
fi
673684
# Ignore: Double quote to prevent globbing and word splitting.
674685
# It's intentional here for $images.
675686
# shellcheck disable=SC2086
676-
if ! run env $images "${deploy_hostpath}"; then
687+
if ! run env "CSI_PROW_TEST_DRIVER=${CSI_PROW_WORK}/test-driver.yaml" $images "${deploy_driver}"; then
677688
# Collect information about failed deployment before failing.
678689
collect_cluster_info
679690
(start_loggers >/dev/null; wait)
680691
info "For container output see job artifacts."
681-
die "deploying the hostpath driver with ${deploy_hostpath} failed"
692+
die "deploying the CSI driver with ${deploy_driver} failed"
682693
fi
683694
}
684695

@@ -804,33 +815,6 @@ install_sanity () (
804815
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"
805816
)
806817

807-
# The default implementation of this function generates a external
808-
# driver test configuration for the hostpath driver.
809-
#
810-
# The content depends on both what the E2E suite expects and what the
811-
# installed hostpath driver supports. Generating it here seems prone
812-
# to breakage, but it is uncertain where a better place might be.
813-
generate_test_driver () {
814-
cat <<EOF
815-
ShortName: csiprow
816-
StorageClass:
817-
FromName: true
818-
SnapshotClass:
819-
FromName: true
820-
DriverInfo:
821-
Name: ${CSI_PROW_HOSTPATH_DRIVER_NAME}
822-
Capabilities:
823-
block: true
824-
persistence: true
825-
dataSource: true
826-
multipods: true
827-
nodeExpansion: true
828-
controllerExpansion: true
829-
snapshotDataSource: true
830-
singleNodeVolume: true
831-
EOF
832-
}
833-
834818
# Captures pod output while running some other command.
835819
run_with_loggers () (
836820
loggers=$(start_loggers -f)
@@ -852,8 +836,6 @@ run_e2e () (
852836
install_e2e || die "building e2e.test failed"
853837
install_ginkgo || die "installing ginkgo failed"
854838

855-
generate_test_driver >"${CSI_PROW_WORK}/test-driver.yaml" || die "generating test-driver.yaml failed"
856-
857839
# Rename, merge and filter JUnit files. Necessary in case that we run the E2E suite again
858840
# and to avoid the large number of "skipped" tests that we get from using
859841
# the full Kubernetes E2E testsuite while only running a few tests.
@@ -1063,7 +1045,7 @@ main () {
10631045
cmds="$(grep '^\s*CMDS\s*=' Makefile | sed -e 's/\s*CMDS\s*=//')"
10641046
# Get the image that was just built (if any) from the
10651047
# top-level Makefile CMDS variable and set the
1066-
# deploy-hostpath.sh env variables for it. We also need to
1048+
# deploy.sh env variables for it. We also need to
10671049
# side-load those images into the cluster.
10681050
for i in $cmds; do
10691051
e=$(echo "$i" | tr '[:lower:]' '[:upper:]' | tr - _)
@@ -1101,7 +1083,7 @@ main () {
11011083
fi
11021084

11031085
# Installing the driver might be disabled.
1104-
if install_hostpath "$images"; then
1086+
if ${CSI_PROW_DRIVER_INSTALL} "$images"; then
11051087
collect_cluster_info
11061088

11071089
if sanity_enabled; then
@@ -1158,7 +1140,7 @@ main () {
11581140
fi
11591141

11601142
# Installing the driver might be disabled.
1161-
if install_hostpath "$images"; then
1143+
if ${CSI_PROW_DRIVER_INSTALL} "$images"; then
11621144
collect_cluster_info
11631145

11641146
if tests_enabled "parallel-alpha"; then

0 commit comments

Comments
 (0)