Skip to content

Commit

Permalink
prow.sh: allow shell commands in CSI_PROW_SANITY_POD
Browse files Browse the repository at this point in the history
This is required for distributed provisioning where the Pod name is
dynamically generated as part of the DaemonSet.
  • Loading branch information
pohly committed May 27, 2021
1 parent 71c810a commit c5f59c5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,17 @@ run_e2e () (
run_sanity () (
install_sanity || die "installing csi-sanity failed"
if [[ "${CSI_PROW_SANITY_POD}" =~ " " ]]; then
# Contains spaces, more complex than a simple pod name.
# Evaluate as a shell command.
pod=$(eval "${CSI_PROW_SANITY_POD}") || die "evaluation failed: CSI_PROW_SANITY_POD=${CSI_PROW_SANITY_POD}"
else
pod="${CSI_PROW_SANITY_POD}"
fi
cat >"${CSI_PROW_WORK}/mkdir_in_pod.sh" <<EOF
#!/bin/sh
kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- mkdir "\$@" && echo "\$@"
kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- mkdir "\$@" && echo "\$@"
EOF
# Using "rm -rf" as fallback for "rmdir" is a workaround for:
# Node Service
Expand All @@ -1023,8 +1031,8 @@ EOF
# why it happened.
cat >"${CSI_PROW_WORK}/rmdir_in_pod.sh" <<EOF
#!/bin/sh
if ! kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- rmdir "\$@"; then
kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- rm -rf "\$@"
if ! kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- rmdir "\$@"; then
kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- rm -rf "\$@"
exit 1
fi
EOF
Expand All @@ -1043,7 +1051,7 @@ else
fi
SCRIPT
)
kubectl exec "${CSI_PROW_SANITY_POD}" -c "${CSI_PROW_SANITY_CONTAINER}" -- /bin/sh -c "\${CHECK_PATH}"
kubectl exec "$pod" -c "${CSI_PROW_SANITY_CONTAINER}" -- /bin/sh -c "\${CHECK_PATH}"
EOF
chmod u+x "${CSI_PROW_WORK}"/*dir_in_pod.sh
Expand Down

0 comments on commit c5f59c5

Please sign in to comment.