Skip to content
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

Add warm pool with new ASG lifecycle hooks #966

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
19d047a
Add Warm Pool
nitrocode May 4, 2021
1671a30
Merge remote-tracking branch 'nitrocode/warm-pool' into keithduncan/a…
keithduncan Nov 25, 2021
01aa09b
Make the boothook conditional on warm pool
keithduncan Nov 25, 2021
28a111c
Give the automation role permission to invoke autoscaling:TerminateIn…
keithduncan Nov 25, 2021
e0cded6
Make the if condition multi-line
keithduncan Nov 25, 2021
4dc5b28
Switch the asg between launch template specification, and mixed insta…
keithduncan Nov 25, 2021
2d6966e
Disable validate for now
keithduncan Nov 25, 2021
ca7ef36
Disable template validation for now
keithduncan Nov 25, 2021
3b081bb
Store the built template on S3 for validation and create-stack
keithduncan Nov 26, 2021
d898596
TemplateURL takes a non-s3 scheme url
keithduncan Nov 26, 2021
2d63aa1
Remove the AllowedPattern from the instance types list
keithduncan Nov 26, 2021
a3e5497
Try [ !Condition ]
keithduncan Nov 26, 2021
44618b6
Break the if not into its own condition
keithduncan Nov 26, 2021
8f53bef
Remove rule for now
keithduncan Nov 26, 2021
bf9f36a
Add separate warmed:pending:wait and pending:wait automations
keithduncan Nov 30, 2021
d396512
Thread the lifecycle action token to the automation and autoscaling:C…
keithduncan Nov 30, 2021
ec9be95
Update the rule descriptions
keithduncan Nov 30, 2021
2998574
Wait for cloud-init to complete before moving from Warmed:Pending:Wait
keithduncan Nov 30, 2021
12ea7c9
Add missing instance id parameter in the warmed automation document
keithduncan Nov 30, 2021
cfd8364
Fix install script to use same BUILDKITE_WARM_POOL var as userdata
keithduncan Nov 30, 2021
fea9572
Make the WarmPool resource depend on the EventBridge rules (which dep…
keithduncan Nov 30, 2021
da402c9
Wait for cloud-init to finish before starting the agent when launched…
keithduncan Nov 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .buildkite/steps/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ echo "--- Building templates"
make "mappings-for-${os}-${arch}-image" build/aws-stack.yml "IMAGE_ID=$image_id"

echo "--- Validating templates"
make validate
make validate "BUCKET_PREFIX=$stack_name"

echo "--- Creating stack ${stack_name}"
make create-stack "STACK_NAME=$stack_name" "SERVICE_ROLE=$service_role"
make create-stack "BUCKET_PREFIX=$stack_name" "STACK_NAME=$stack_name" "SERVICE_ROLE=$service_role"

echo "+++ ⌛️ Waiting for update to complete"
./parfait watch-stack "${stack_name}"
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ ifdef SERVICE_ROLE
role_arn="--role-arn=$(SERVICE_ROLE)"
endif

create-stack: build/aws-stack.yml env-STACK_NAME
create-stack: build/aws-stack.yml env-STACK_NAME env-BUILDKITE_AWS_STACK_BUCKET env-BUCKET_PREFIX
aws s3 cp --content-type 'text/yaml' --acl public-read build/aws-stack.yml "s3://$(BUILDKITE_AWS_STACK_BUCKET)/$(BUCKET_PREFIX)/aws-stack.yml"
aws cloudformation create-stack \
--output text \
--stack-name $(STACK_NAME) \
--disable-rollback \
--template-body "file://$(PWD)/build/aws-stack.yml" \
--template-url "https://$(BUILDKITE_AWS_STACK_BUCKET).s3.amazonaws.com/$(BUCKET_PREFIX)/aws-stack.yml" \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
--parameters "$$(cat config.json)" \
"$(role_arn)"
Expand All @@ -175,10 +176,11 @@ bump-agent-version:
git add README.md packer/linux/scripts/install-buildkite-agent.sh packer/windows/scripts/install-buildkite-agent.ps1
git commit -m "Bump buildkite-agent to v$(AGENT_VERSION)"

validate: build/aws-stack.yml
validate: build/aws-stack.yml env-BUILDKITE_AWS_STACK_BUCKET env-BUCKET_PREFIX
aws s3 cp --content-type 'text/yaml' --acl public-read build/aws-stack.yml "s3://$(BUILDKITE_AWS_STACK_BUCKET)/$(BUCKET_PREFIX)/aws-stack.yml"
aws cloudformation validate-template \
--output text \
--template-body "file://$(PWD)/build/aws-stack.yml"
--template-url "https://$(BUILDKITE_AWS_STACK_BUCKET).s3.amazonaws.com/$(BUCKET_PREFIX)/aws-stack.yml"

generate-toc:
docker run -it --rm -v "$(PWD):/app" node:slim bash \
Expand Down
6 changes: 6 additions & 0 deletions packer/linux/conf/bin/bk-install-elastic-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ fi

systemctl enable "buildkite-agent"

# If warm pool is enabled, don't start the agent until the ASG BootHook
if [ "${BUILDKITE_WARM_POOL:-false}" == "false" ]
then
systemctl start "buildkite-agent"
fi

# let the stack know that this host has been initialized successfully
/opt/aws/bin/cfn-signal \
--region "$AWS_REGION" \
Expand Down
5 changes: 5 additions & 0 deletions packer/windows/conf/bin/bk-install-elastic-stack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ If ($lastexitcode -ne 0) { Exit $lastexitcode }
nssm set buildkite-agent AppRestartDelay 5000
If ($lastexitcode -ne 0) { Exit $lastexitcode }

# If warm pool is enabled, don't start the agent until the ASG BootHook
If ($null -eq $Env:BUILDKITE_WARM_POOL -or $Env:BUILDKITE_WARM_POOL -eq "false") {
Restart-Service buildkite-agent
}

# renable debug tracing
Set-PSDebug -Trace 2

Expand Down
Loading