Skip to content

Commit 25793ca

Browse files
author
Chloe Hutchinson
committed
Revise approach, teardown temp directory on pre-exit
This also fixes a shellcheck error SC2155 Instead of setting DOCKER_CONFIG directly, set BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY and hydrate DOCKER_CONFIG for plugin steps. if this gets overriden by the user, they can manage their own DOCKER_CONFIG cleanup activities and we will always remove the temporary directory from the agent instance filesystem.
1 parent 18bc05b commit 25793ca

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

packer/linux/conf/buildkite-agent/hooks/environment

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ set -eu -o pipefail
55
source ~/cfn-env
66

77
# a clean docker config for each job, for improved isolation
8-
export DOCKER_CONFIG=$(mktemp -d)
8+
BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY=$(mktemp -d)
9+
export BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY
10+
export DOCKER_CONFIG="$BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY"
911

1012
echo "~~~ :llama: Setting up elastic stack environment ($BUILDKITE_STACK_VERSION)"
1113
cat ~/cfn-env

packer/linux/conf/buildkite-agent/hooks/pre-exit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
set -eu -o pipefail
44

5+
# clean up our temporary docker config
6+
if [[ -n "${BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY:-}" ]]; then
7+
rmdir ${BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY}
8+
fi
9+
510
if [[ -n "${BUILDKITE_SECRETS_BUCKET:-}" && "${SECRETS_PLUGIN_ENABLED:-}" == "1" ]] ; then
611
export BUILDKITE_PLUGIN_S3_SECRETS_BUCKET="$BUILDKITE_SECRETS_BUCKET"
712

packer/windows/conf/buildkite-agent/hooks/environment

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ set -eu -o pipefail
55
source ~/cfn-env
66

77
# a clean docker config for each job, for improved isolation
8-
export DOCKER_CONFIG=$(mktemp -d)
8+
BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY=$(mktemp -d)
9+
export BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY
10+
export DOCKER_CONFIG="$BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY"
911

1012
echo "~~~ :llama: Setting up elastic stack environment ($BUILDKITE_STACK_VERSION)"
1113
cat ~/cfn-env

packer/windows/conf/buildkite-agent/hooks/pre-exit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
set -eu -o pipefail
44

5+
# clean up our temporary docker config
6+
if [[ -n "${BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY:-}" ]]; then
7+
rmdir ${BUILDKITE_DOCKER_CONFIG_TEMP_DIRECTORY}
8+
fi
9+
510
if [[ -n "${BUILDKITE_SECRETS_BUCKET:-}" && "${SECRETS_PLUGIN_ENABLED:-}" == "1" ]] ; then
611
export BUILDKITE_PLUGIN_S3_SECRETS_BUCKET="$BUILDKITE_SECRETS_BUCKET"
712

0 commit comments

Comments
 (0)