Skip to content

Commit

Permalink
Update .prow.sh to enable volume mode conversion
Browse files Browse the repository at this point in the history
in e2e tests running in provisioner repo
  • Loading branch information
RaunakShah committed Dec 21, 2022
1 parent 6b76e94 commit 9a0fd9c
Showing 1 changed file with 52 additions and 20 deletions.
72 changes: 52 additions & 20 deletions .prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,59 @@

. release-tools/prow.sh

# External-provisioner is updated to use VolumeSnapshot v1 APIs. As a result,
# tesing on Kubernetes version < 1.20 are no longer supported because they use
# v1beta1 or earlier VolumeSnapshot APIs.
# TODO: The check can be removed when all Prow jobs for Kubernetes < 1.20 are removed.
if ! (version_gt "${CSI_PROW_KUBERNETES_VERSION}" "1.19.255" || [ "${CSI_PROW_KUBERNETES_VERSION}" == "latest" ]); then
filtered_tests=
skipped_tests=
for test in ${CSI_PROW_TESTS}; do
case "$test" in
parallel | serial | parallel-alpha | serial-alpha)
skipped_tests="$skipped_tests $test"
;;
*)
filtered_tests="$filtered_tests $test"
;;
esac
volume_mode_conversion () {
[ "${VOLUME_MODE_CONVERSION_TESTS}" == "true" ]
}

if volume_mode_conversion; then
install_snapshot_controller() {
CONTROLLER_DIR="https://raw.githubusercontent.com/RaunakShah/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}"
if [[ ${REPO_DIR} == *"external-snapshotter"* ]]; then
CONTROLLER_DIR="${REPO_DIR}"
fi
SNAPSHOT_RBAC_YAML="${CONTROLLER_DIR}/deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
echo "kubectl apply -f ${SNAPSHOT_RBAC_YAML}"
# Ignore: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086
kubectl apply -f ${SNAPSHOT_RBAC_YAML}

cnt=0
until kubectl get clusterrolebinding snapshot-controller-role; do
if [ $cnt -gt 30 ]; then
echo "Cluster role bindings:"
kubectl describe clusterrolebinding
echo >&2 "ERROR: snapshot controller RBAC not ready after over 5 min"
exit 1
fi
echo "$(date +%H:%M:%S)" "waiting for snapshot RBAC setup complete, attempt #$cnt"
cnt=$((cnt + 1))
sleep 10
done

SNAPSHOT_CONTROLLER_YAML="${CSI_PROW_WORK}/snapshot-controller.yaml"
run curl "${CONTROLLER_DIR}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml" --output "${SNAPSHOT_CONTROLLER_YAML}" --silent --location

echo "Enabling prevent-volume-mode-conversion in snapshot-controller"
sed -i -e 's/# end snapshot controller args/- \"--prevent-volume-mode-conversion=true\"\n # end snapshot controller args/' "${SNAPSHOT_CONTROLLER_YAML}"

echo "kubectl apply -f $SNAPSHOT_CONTROLLER_YAML"
kubectl apply -f "$SNAPSHOT_CONTROLLER_YAML"

cnt=0
expected_running_pods=$(kubectl apply --dry-run=client -o "jsonpath={.spec.replicas}" -f "$SNAPSHOT_CONTROLLER_YAML")
expected_namespace=$(kubectl apply --dry-run=client -o "jsonpath={.metadata.namespace}" -f "$SNAPSHOT_CONTROLLER_YAML")
while [ "$(kubectl get pods -n "$expected_namespace" -l app=snapshot-controller | grep 'Running' -c)" -lt "$expected_running_pods" ]; do
if [ $cnt -gt 30 ]; then
echo "snapshot-controller pod status:"
kubectl describe pods -n "$expected_namespace" -l app=snapshot-controller
echo >&2 "ERROR: snapshot controller not ready after over 5 min"
exit 1
fi
echo "$(date +%H:%M:%S)" "waiting for snapshot controller deployment to complete, attempt #$cnt"
cnt=$((cnt + 1))
sleep 10
done
if [ "$skipped_tests" ]; then
info "Testing on Kubernetes ${CSI_PROW_KUBERNETES_VERSION} is no longer supported. Skipping CSI_PROW_TESTS: $skipped_tests."
CSI_PROW_TESTS="$filtered_tests"
fi
}
fi

main

0 comments on commit 9a0fd9c

Please sign in to comment.