Skip to content

Commit

Permalink
Merge pull request #320 from buildkite/bring-back-lifecycled
Browse files Browse the repository at this point in the history
Add lifecycled back, replace shudder
  • Loading branch information
lox authored Aug 10, 2017
2 parents cb32d01 + c5e4e7f commit 326c4a8
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .buildkite/steps/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ s3_upload_templates() {
aws s3 cp --acl public-read templates/mappings.yml "s3://buildkite-aws-stack/${bucket_prefix}mappings.yml"
aws s3 cp --acl public-read build/aws-stack.json "s3://buildkite-aws-stack/${bucket_prefix}aws-stack.json"
aws s3 cp --acl public-read build/aws-stack.yml "s3://buildkite-aws-stack/${bucket_prefix}aws-stack.yml"

echo "Published https://s3.amazonaws.com/buildkite-aws-stack/${bucket_prefix}mappings.yml"
echo "Published https://s3.amazonaws.com/buildkite-aws-stack/${bucket_prefix}aws-stack.json"
echo "Published https://s3.amazonaws.com/buildkite-aws-stack/${bucket_prefix}aws-stack.yml"
}

git fetch --tags
Expand Down
2 changes: 1 addition & 1 deletion packer/buildkite-ami.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
{
"type": "shell",
"script": "scripts/install-shudder.sh"
"script": "scripts/install-lifecycled.sh"
},
{
"type": "shell",
Expand Down
12 changes: 5 additions & 7 deletions packer/conf/bin/bk-install-elastic-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,14 @@ if [[ -n "${BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT}" ]] ; then
rm /tmp/elastic_bootstrap
fi

cat << EOF > /etc/shudder/shudder.toml
sqs_prefix = "${BUILDKITE_STACK_NAME}"
region = "${AWS_REGION}"
sns_topic = "${BUILDKITE_LIFECYCLE_TOPIC}"
commands = [["/usr/local/bin/stop-agent-gracefully"]]
cat << EOF > /etc/lifecycled
AWS_REGION=${AWS_REGION}
LIFECYCLED_SNS_TOPIC=${BUILDKITE_LIFECYCLE_TOPIC}
LIFECYCLED_HANDLER=/usr/local/bin/stop-agent-gracefully
EOF

# my kingdom for a decent init system
start terminationd || true
start shudder || true
start lifecycled || true
service awslogs restart || true

# wait for docker to start
Expand Down
12 changes: 12 additions & 0 deletions packer/conf/lifecycled/upstart/lifecycled.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
start on startup
respawn
script
set -a
. /etc/lifecycled
mkfifo /tmp/lifecycled-log-fifo
( logger -t lifecycled </tmp/lifecycled-log-fifo & )
exec >/tmp/lifecycled-log-fifo
exec 2>&1
rm /tmp/lifecycled-log-fifo
exec /usr/bin/lifecycled
end script
16 changes: 0 additions & 16 deletions packer/conf/shudder/upstart/shudder.conf

This file was deleted.

13 changes: 13 additions & 0 deletions packer/scripts/install-lifecycled.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -eu -o pipefail

LIFECYCLED_VERSION=v2.0.0-rc2

echo "Installing lifecycled..."

sudo touch /etc/lifecycled
sudo curl -Lf -o /usr/bin/lifecycled \
https://github.com/lox/lifecycled/releases/download/${LIFECYCLED_VERSION}/lifecycled-linux-amd64
sudo chmod +x /usr/bin/lifecycled
sudo curl -Lf -o /etc/init/lifecycled.conf \
https://raw.githubusercontent.com/lox/lifecycled/${LIFECYCLED_VERSION}/init/upstart/lifecycled.conf
7 changes: 0 additions & 7 deletions packer/scripts/install-shudder.sh

This file was deleted.

9 changes: 7 additions & 2 deletions templates/buildkite-elastic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Resources:
Statement:
- Effect: Allow
Principal:
Service: [ ec2.amazonaws.com ]
Service: [ autoscaling.amazonaws.com, ec2.amazonaws.com ]
Action: sts:AssumeRole
Path: /

Expand Down Expand Up @@ -371,7 +371,12 @@ Resources:
- logs:PutLogEvents
- logs:DescribeLogStreams
Resource: "*"

- Effect: Allow
Action:
- sqs:*
- sns:Unsubscribe
- sns:Subscribe
Resource: "*"
Roles:
- { Ref: IAMRole }

Expand Down
4 changes: 2 additions & 2 deletions tests/agent.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[ $status = 0 ]
}

@test "Check shudder is running" {
run status "shudder"
@test "Check lifecycled is running" {
run status "lifecycled"
[ $status = 0 ]
}

0 comments on commit 326c4a8

Please sign in to comment.