Handle failures during `setup.sh`
Created by: julianhess
This requires splitting it into two: setup.sh
and localization.sh
. Previously, setup.sh
did three things:
- Create directory structure for the task
- Export environment variables for the task
- Perform any localization tasks (i.e.,
gsutil cp|cat
) for the task
We need to be able to catch errors arising from the third (localization) step.
However, the first two steps need to be sourced in entrypoint.sh
, since they
export variables that must be available to script.sh
when it's subsequently
invoked in entrypoint.sh
. Sourcing all three steps makes it difficult to recover
any error codes from the localization step.
Thus, we now source the first two steps in entrypoint.sh
(via setup.sh
),
and break the localization tasks out into their own script (localization.sh
),
which entrypoint.sh
runs. By recovering the exit code of localization.sh
, we
can infer whether the localization tasks failed
The first couple commits in this PR represent a flawed approach: wrapping everything in setup.sh
with set -e
/set +e
was problematic because it prevents teardown.sh
from ever running — since set -e
get sourced, any errors during localization halt entrypoint.sh
immediately.