cap API quota for runner-utilization / amd-ci-job-monitor (#25965)

This commit is contained in:
Liangsheng Yin
2026-05-21 01:13:37 -07:00
committed by GitHub
parent c3f9bc9818
commit 1b3d8da827
4 changed files with 38 additions and 5 deletions
+15 -1
View File
@@ -19,9 +19,21 @@ on:
required: false required: false
type: string type: string
# Bound the API cost when the same ref pushes repeatedly. See note in
# runner-utilization.yml for the original incident this guards against.
concurrency:
group: amd-ci-job-monitor-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
fetch-actions-data: fetch-actions-data:
name: Fetch Actions Snapshot name: Fetch Actions Snapshot
# Skip fork PRs entirely, and require the `run-ci` label on same-repo PRs.
# schedule and workflow_dispatch always run.
if: >-
github.event_name != 'pull_request' ||
(github.event.pull_request.head.repo.full_name == github.repository &&
contains(github.event.pull_request.labels.*.name, 'run-ci'))
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -49,10 +61,12 @@ jobs:
- name: Fetch Actions data snapshot - name: Fetch Actions data snapshot
timeout-minutes: 30 timeout-minutes: 30
run: | run: |
# PR-trigger is just a script smoke check; scan a 20-minute window
# (0.34h) to bound API cost. schedule / dispatch run the full report.
python scripts/ci/utils/query_job_status.py \ python scripts/ci/utils/query_job_status.py \
--repo ${{ github.repository }} \ --repo ${{ github.repository }} \
--workflow "${{ steps.select-workflows.outputs.workflows }}" \ --workflow "${{ steps.select-workflows.outputs.workflows }}" \
--hours ${{ inputs.hours || '24' }} \ --hours ${{ (github.event_name == 'pull_request' && '0.34') || inputs.hours || '24' }} \
--dump-data-file actions-job-snapshot.json --dump-data-file actions-job-snapshot.json
- name: Upload Actions data snapshot - name: Upload Actions data snapshot
+18 -1
View File
@@ -19,9 +19,24 @@ on:
required: false required: false
type: string type: string
# Sandbox PRs (e.g. tom/kv_canary) push dozens of times in a row. Without this
# group, every push spawns another 24h API scan that races the previous ones
# and drains the shared 15k/hr installation token quota. Cancel-in-progress
# keeps at most one Runner Utilization run per ref alive at a time.
concurrency:
group: runner-utilization-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
report: report:
name: Generate Report name: Generate Report
# Skip fork PRs entirely, and require the `run-ci` label on same-repo PRs
# so unlabeled iteration pushes (e.g. long-lived sandbox branches) don't
# fire the 24h API scan. schedule and workflow_dispatch always run.
if: >-
github.event_name != 'pull_request' ||
(github.event.pull_request.head.repo.full_name == github.repository &&
contains(github.event.pull_request.labels.*.name, 'run-ci'))
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
@@ -37,7 +52,9 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
# PR-trigger is just a script smoke check; scan a 20-minute window
# (0.34h) to bound API cost. schedule / dispatch run the full report.
python scripts/ci/utils/runner_utilization_report.py \ python scripts/ci/utils/runner_utilization_report.py \
--repo ${{ github.repository }} \ --repo ${{ github.repository }} \
--hours ${{ inputs.hours || '24' }} \ --hours ${{ (github.event_name == 'pull_request' && '0.34') || inputs.hours || '24' }} \
${{ inputs.filter && format('--filter {0}', inputs.filter) || '' }} ${{ inputs.filter && format('--filter {0}', inputs.filter) || '' }}
+2 -2
View File
@@ -1724,9 +1724,9 @@ def main():
) )
parser.add_argument( parser.add_argument(
"--hours", "--hours",
type=int, type=float,
default=24, default=24,
help="Time window in hours (default: 24)", help="Time window in hours (fractional ok, default: 24)",
) )
parser.add_argument( parser.add_argument(
"--status", "--status",
@@ -599,7 +599,9 @@ def format_report(
def main(): def main():
parser = argparse.ArgumentParser(description="Generate runner utilization report") parser = argparse.ArgumentParser(description="Generate runner utilization report")
parser.add_argument("--repo", default="sgl-project/sglang", help="GitHub repo") parser.add_argument("--repo", default="sgl-project/sglang", help="GitHub repo")
parser.add_argument("--hours", type=int, default=24, help="Time window in hours") parser.add_argument(
"--hours", type=float, default=24, help="Time window in hours (fractional ok)"
)
parser.add_argument( parser.add_argument(
"--filter", type=str, help="Filter runner labels (e.g., '5090', 'h200')" "--filter", type=str, help="Filter runner labels (e.g., '5090', 'h200')"
) )