Skip to content

Commit 55fbe54

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 692b6f4 commit 55fbe54

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
@@ -33,7 +33,7 @@ jobs:
3333
inlineScript: |
3434
active_vms=$(az vm list -g ${{ secrets.AZURE_RESOURCE_GROUP }} | jq -c '.[] | {name,timeCreated}')
3535
current_time=$(date +%s)
36-
three_hours_ago=$(($current_time - 3 * 3600))
36+
one_hour_ago=$(($current_time - 3600))
3737
3838
if [ -z "$active_vms" ]; then
3939
echo "No active VMs found, nothing to do."
@@ -48,8 +48,8 @@ jobs:
4848
vm_creation_iso_string=$(echo $active_vm | jq -r '.timeCreated')
4949
vm_creation_time=$(date -d $vm_creation_iso_string +%s)
5050
51-
if [ "$three_hours_ago" -lt "$vm_creation_time" ]; then
52-
echo "The VM ${vm_name} was created less then 3 hours ago and shouldn't be deleted yet. Skipping."
51+
if [ "$one_hour_ago" -lt "$vm_creation_time" ]; then
52+
echo "The VM ${vm_name} was created less then 1 hour ago and shouldn't be deleted yet. Skipping."
5353
elif test true = "$(if test ! -f .cli-authenticated; then
5454
./gh-cli-auth-as-app.sh &&
5555
>.cli-authenticated # only authenticate once

0 commit comments

Comments
 (0)