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

Instance lifetime timeout #836

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions packer/linux/conf/bin/bk-install-elastic-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ if ! docker ps ; then
exit 1
fi

systemctl enable "buildkite-agent"
systemctl start "buildkite-agent"
systemctl enable --now "buildkite-agent"

systemctl enable --now "buildkite-agent-soft-limit.timer"
systemctl enable --now "buildkite-agent-hard-limit.timer"

# let the stack know that this host has been initialized successfully
/opt/aws/bin/cfn-signal \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Hard stop buildkite agent

[Service]
ExecStart=/bin/systemctl stop buildkite-agent
RemainAfterExit=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Initiate hard stop of agent
After=buildkite-agent.service

[Timer]
# 3hr soft timer + 21hr grace period
OnBootSec=24hr

[Install]
WantedBy=timers.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Soft stop buildkite agent

[Service]
ExecStart=/bin/systemctl kill --signal=TERM --kill-who=main buildkite-agent
RemainAfterExit=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Initiate soft stop of agent
After=buildkite-agent.service

[Timer]
OnBootSec=3hr

[Install]
WantedBy=timers.target
3 changes: 2 additions & 1 deletion packer/linux/scripts/install-buildkite-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ sudo mkdir -p /var/lib/buildkite-agent/plugins
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
sudo cp /tmp/conf/buildkite-agent/systemd/*.service /etc/systemd/system/
sudo cp /tmp/conf/buildkite-agent/systemd/*.timer /etc/systemd/system/

echo "Adding cloud-init failure safety check..."
sudo mkdir -p /etc/systemd/system/cloud-final.service.d/
Expand Down