Skip to content

Commit 2d1ebde

Browse files
committed
cleanup-self-hosted-runner: clean up idle runners earlier
The original idea was to wait at least 3 hours before deleting a VM, to avoid interfering with long-running workflows. Now that we have a way to query whether the runner _is_ busy, we do not need to wait that long. Basically, we only need to ensure that the runner had a chance to register itself and to then pick up the job. Typically, this takes around 6-7 minutes, so waiting for an hour is probably even a tad conservative. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f355727 commit 2d1ebde

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.github/workflows/cleanup-self-hosted-runners.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
inlineScript: |
3535
active_vms=$(az vm list -g ${{ secrets.AZURE_RESOURCE_GROUP }} | jq -c '.[] | {name,timeCreated}')
3636
current_time=$(date +%s)
37-
three_hours_ago=$(($current_time - 3 * 3600))
37+
one_hour_ago=$(($current_time - 3600))
3838
3939
if [ -z "$active_vms" ]; then
4040
echo "No active VMs found, nothing to do."
@@ -51,8 +51,8 @@ jobs:
5151
jq -r '.timeCreated | sub("\\.[0-9]+[+-][0-9]+:[0-9]+$"; "") | sub("T"; " ")')"
5252
vm_creation_time=$(TZ=UTC date -d "$vm_creation_time_string" +%s)
5353
54-
if [ "$three_hours_ago" -lt "$vm_creation_time" ]; then
55-
echo "The VM ${vm_name} was created less then 3 hours ago and shouldn't be deleted yet. Skipping."
54+
if [ "$one_hour_ago" -lt "$vm_creation_time" ]; then
55+
echo "The VM ${vm_name} was created less then 1 hour ago and shouldn't be deleted yet. Skipping."
5656
elif test true = "$(if test ! -f .cli-authenticated; then
5757
./gh-cli-auth-as-app.sh &&
5858
>.cli-authenticated # only authenticate once

0 commit comments

Comments
 (0)