-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tasks: Introduce elastic cloud runner mode
As the EC2 bare metal instances are expensive, We don't want them to run permanently, but only in times of high demand. They should then terminate themselves when the queue is running out of work. Define "run out of work" as "the number of job-runner entries in the AMQP queue drops below 10". At that level, our permanent PSI runners can keep up. This is are more robust global criterion than checking if `run-queue` encountered an empty queue, as this is more prone to terminating only *some* of the instances while some others keep picking up brand new queue entries. Introduce an "idle poweroff" mode in which the `cockpit-tasks` main loop exits with code 100 instead of slumbering when work is running low. Configure the slice to automatically power off the machine once all cockpit-tasks instances exited cleanly (we don't want this on failures, so that we can ssh in and examine them). Use the `poweroff-immediate` heavy hammer there, to avoid potential hangs on shutdown -- there is nothing to rescue from the instance anyway. Plumb that through the AWS Ansible role and document it.
- Loading branch information
1 parent
48c4c49
commit 989c817
Showing
4 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,9 @@ After=podman.socket | |
[Service] | ||
Slice=cockpittasks.slice | ||
Restart=always | ||
# cockpit-tasks exits with 100 in IDLE_POWEROFF mode when queue is running low | ||
SuccessExitStatus=100 | ||
RestartPreventExitStatus=100 | ||
RestartSec=60 | ||
# give image pull enough time | ||
TimeoutStartSec=10min | ||
|
@@ -63,13 +66,24 @@ ExecStart=/usr/bin/podman run --name=cockpit-tasks-%i --hostname=${CONTAINER_HOS | |
[email protected] \ | ||
--env=TEST_NOTIFICATION_MX=${TEST_NOTIFICATION_MX} \ | ||
--env=TEST_NOTIFICATION_TO=${TEST_NOTIFICATION_TO} \ | ||
--env=IDLE_POWEROFF=${IDLE_POWEROFF:-} \ | ||
ghcr.io/cockpit-project/tasks cockpit-tasks --verbose | ||
ExecStop=/usr/bin/podman rm -f cockpit-tasks-%i | ||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
|
||
# mode for elastic cloud runners | ||
if [ -n "${IDLE_POWEROFF:-}" ]; then | ||
mkdir -p /etc/systemd/system/cockpittasks.slice.d | ||
cat <<EOF > /etc/systemd/system/cockpittasks.slice.d/poweroff.conf | ||
[Unit] | ||
StopWhenUnneeded=yes | ||
SuccessAction=poweroff-immediate | ||
EOF | ||
fi | ||
|
||
systemctl daemon-reload | ||
|
||
for i in `seq $INSTANCES`; do systemctl enable --now cockpit-tasks@$i; done |