-
Notifications
You must be signed in to change notification settings - Fork 313
fix: remove EXIT trap from wait_for_available_zone.sh #6154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,6 @@ | |||||||||||||||||
| # to prevent it from killing the pod. | ||||||||||||||||||
| ZONE_EXPORT=$(mktemp) | ||||||||||||||||||
| ZONE_OUTPUT=$(mktemp) | ||||||||||||||||||
| trap 'rm -f "$ZONE_EXPORT" "$ZONE_OUTPUT"' EXIT | ||||||||||||||||||
|
|
||||||||||||||||||
| while true; do | ||||||||||||||||||
| # Run the script in a subshell, streaming stdout and stderr to the console and a log file. | ||||||||||||||||||
|
|
@@ -45,10 +44,10 @@ while true; do | |||||||||||||||||
| sleep 300 | ||||||||||||||||||
| else | ||||||||||||||||||
| echo "--- FATAL ERROR: find_available_zone.sh failed due to a configuration or system error. Exiting. ---" >&2 | ||||||||||||||||||
| rm -f "$ZONE_EXPORT" "$ZONE_OUTPUT" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
|
Comment on lines
+47
to
48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this script is sourced by a parent shell, calling
Suggested change
|
||||||||||||||||||
| fi | ||||||||||||||||||
| fi | ||||||||||||||||||
| done | ||||||||||||||||||
|
|
||||||||||||||||||
| rm -f "$ZONE_EXPORT" "$ZONE_OUTPUT" | ||||||||||||||||||
| trap - EXIT | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sourcing this script will permanently alter the parent shell's
errexit(set -e) setting because of theset +eandset -ecalls inside the loop (lines 25 and 34). If the parent shell hadset -edisabled, it will end up withset -eenabled after sourcing this script.To prevent this side-effect, consider saving the original state of
errexitat the beginning of the script and restoring it at the end: