Skip to content

Commit

Permalink
Merge pull request #638 from dbaggerman/fix-stuck-instances
Browse files Browse the repository at this point in the history
Power off immediately if cloud-init fails
  • Loading branch information
lox committed Oct 23, 2019
2 parents db97804 + 86eb2a8 commit 70a6590
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Unit]
OnFailure=poweroff.target
OnFailureJobMode=replace-irreversibly
3 changes: 3 additions & 0 deletions packer/linux/scripts/install-buildkite-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ sudo chown -R buildkite-agent: /var/lib/buildkite-agent/plugins
echo "Adding systemd service template..."
sudo cp /tmp/conf/buildkite-agent/systemd/buildkite-agent.service /etc/systemd/system/buildkite-agent.service

echo "Adding cloud-init failure safety check..."
sudo cp /tmp/conf/buildkite-agent/systemd/system/cloud-final.service.d/10-power-off-on-failure.conf /etc/systemd/system/cloud-final.service.d/10-power-off-on-failure.conf

echo "Adding termination scripts..."
sudo cp /tmp/conf/buildkite-agent/scripts/stop-agent-gracefully /usr/local/bin/stop-agent-gracefully
sudo cp /tmp/conf/buildkite-agent/scripts/terminate-instance /usr/local/bin/terminate-instance
Expand Down

0 comments on commit 70a6590

Please sign in to comment.