Skip to content

Commit f8a717f

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 a207952 commit f8a717f

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
@@ -29,7 +29,7 @@ jobs:
2929
inlineScript: |
3030
active_vms=$(az vm list -g ${{ secrets.AZURE_RESOURCE_GROUP }} | jq -c '.[] | {name,timeCreated}')
3131
current_time=$(date +%s)
32-
three_hours_ago=$(($current_time - 3 * 3600))
32+
one_hour_ago=$(($current_time - 3600))
3333
3434
if [ -z "$active_vms" ]; then
3535
echo "No active VMs found, nothing to do."
@@ -44,7 +44,7 @@ jobs:
4444
vm_creation_iso_string=$(echo $active_vm | jq -r '.timeCreated')
4545
vm_creation_time=$(date -d $vm_creation_iso_string +%s)
4646
47-
if [ "$three_hours_ago" -lt "$vm_creation_time" ]; then
47+
if [ "$one_hour_ago" -lt "$vm_creation_time" ]; then
4848
echo "The VM ${vm_name} was created less then 3 hours ago and shouldn't be deleted yet. Skipping."
4949
elif test true = "$(gh api repos/$GITHUB_REPOSITORY/actions/runners \
5050
--jq '.runners[] | select(.name == "'$vm_name'") | .busy)"; then

0 commit comments

Comments
 (0)