Skip to content

Commit c4d93f2

Browse files
Patrick Robinsonyob
authored andcommitted
Isolate docker configuration per step
This avoids potential race condition that: - Allow steps to use credential from other steps - Causes steps to use incorrect credentials, if they are over-written by another step
1 parent 4ecfc29 commit c4d93f2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packer/linux/conf/bin/bk-install-elastic-stack.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ PLUGINS_ENABLED=()
4949
[[ $ECR_PLUGIN_ENABLED == "true" ]] && PLUGINS_ENABLED+=("ecr")
5050
[[ $DOCKER_LOGIN_PLUGIN_ENABLED == "true" ]] && PLUGINS_ENABLED+=("docker-login")
5151

52+
[[ $ISOLATE_DOCKER_CONFIG == "true" ]] && DOCKER_CONFIG="export DOCKER_CONFIG=\$(mktemp -d)"
53+
5254
# cfn-env is sourced by the environment hook in builds
5355
cat << EOF > /var/lib/buildkite-agent/cfn-env
5456
export DOCKER_VERSION=$DOCKER_VERSION
@@ -60,6 +62,7 @@ export AWS_DEFAULT_REGION=$AWS_REGION
6062
export AWS_REGION=$AWS_REGION
6163
export PLUGINS_ENABLED="${PLUGINS_ENABLED[*]-}"
6264
export BUILDKITE_ECR_POLICY=${BUILDKITE_ECR_POLICY:-none}
65+
${DOCKER_CONFIG:-""}
6366
EOF
6467

6568
if [[ "${BUILDKITE_AGENT_RELEASE}" == "edge" ]] ; then

templates/aws-stack.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Metadata:
7474
Parameters:
7575
- EnableDockerUserNamespaceRemap
7676
- EnableDockerExperimental
77+
- IsolateDockerConfig
7778

7879
- Label:
7980
default: Docker Registry Configuration
@@ -355,6 +356,14 @@ Parameters:
355356
- "false"
356357
Default: "false"
357358

359+
IsolateDockerConfig:
360+
Type: String
361+
Description: Isolates Docker Configuration per step
362+
AllowedValues:
363+
- "true"
364+
- "false"
365+
Default: "false"
366+
358367
EnableCostAllocationTags:
359368
Type: String
360369
Description: Enables AWS Cost Allocation tags for all resources in the stack. See https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html
@@ -864,6 +873,7 @@ Resources:
864873
$Env:ECR_PLUGIN_ENABLED="${EnableECRPlugin}"
865874
$Env:DOCKER_LOGIN_PLUGIN_ENABLED="${EnableDockerLoginPlugin}"
866875
$Env:AWS_REGION="${AWS::Region}"
876+
$Env:ISOLATE_DOCKER_CONFIG="${IsolateDockerConfig}"
867877
powershell -file C:\buildkite-agent\bin\bk-install-elastic-stack.ps1 >> C:\buildkite-agent\elastic-stack.log
868878
</powershell>
869879
- {

0 commit comments

Comments
 (0)