Skip to content

Commit

Permalink
Linux env hook was too eager, breaking ECR retries
Browse files Browse the repository at this point in the history
When we introduced the `environment` hook error trap in #1179, we set it to
propagate into all `source`-d plugin environment hooks. Unfortunately, this
breaks the `retry` function in the ECR plugin's environment hook (which runs
a command and then checks the exit code to determine whether to retry) by
interrupting execution before the exit code can be checked.

Repro: buildkite-plugins/ecr-buildkite-plugin#101

Fix by temporarily unsetting `-E`, stopping propagation of the trap command
into the plugin environment hook.
  • Loading branch information
lucaswilric committed Mar 4, 2024
1 parent 552b5ef commit c2b49b9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packer/linux/conf/buildkite-agent/hooks/environment
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ if [[ "${BUILDKITE_ECR_POLICY:-}" != "none" && "${ECR_PLUGIN_ENABLED:-}" == "1"
export BUILDKITE_PLUGIN_ECR_ACCOUNT_IDS_0="${AWS_ECR_LOGIN_REGISTRY_IDS}"
fi

# Do not propagate the error trap into the ECR plugin's environment hook, because its 'retry' function breaks when we do that.
set +E

# shellcheck source=/dev/null
source /usr/local/buildkite-aws-stack/plugins/ecr/hooks/environment

set -E
fi

if [[ "${DOCKER_USERNS_REMAP:-false}" == "false" ]]; then
Expand Down

0 comments on commit c2b49b9

Please sign in to comment.