Skip to content

Commit fab1341

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 9645cc1 commit fab1341

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
inlineScript: |
3333
active_vms=$(az vm list -g ${{ secrets.AZURE_RESOURCE_GROUP }} | jq -c '.[] | {name,timeCreated}')
3434
current_time=$(date +%s)
35-
three_hours_ago=$(($current_time - 3 * 3600))
35+
one_hour_ago=$(($current_time - 3600))
3636
3737
if [ -z "$active_vms" ]; then
3838
echo "No active VMs found, nothing to do."
@@ -47,7 +47,7 @@ jobs:
4747
vm_creation_iso_string=$(echo $active_vm | jq -r '.timeCreated')
4848
vm_creation_time=$(date -d $vm_creation_iso_string +%s)
4949
50-
if [ "$three_hours_ago" -lt "$vm_creation_time" ]; then
50+
if [ "$one_hour_ago" -lt "$vm_creation_time" ]; then
5151
echo "The VM ${vm_name} was created less then 3 hours ago and shouldn't be deleted yet. Skipping."
5252
elif test true = "$(if test ! -f .cli-authenticated; then
5353
./gh-cli-auth-as-app.sh &&

0 commit comments

Comments
 (0)