Skip to content

fix(service): the hourly GitHub budget counts only the rounds that end and lets a started round pass it, so the Service sent about 913 requests in an hour against a budget of 500 #2547

Closed

Description

@dan-petty

Problem Description

The roadmap Service's hourly GitHub budget (RequestBudget, src/devops_cli/server/service.py) does not hold the Service to service.github_requests_per_hour. On 2026-10-28, in the hour up to 21:22 UTC, the Service's own telemetry counted about 913 GitHub requests (838 REST, 75 GraphQL). The budget is 500. The budget record of the pod held 614 for the same hour.

There are two causes, both in the design of RequestBudget:

  1. It is soft. It reads the process's request count only when a round ends (record_round), and it only stops a new round from starting. A round that starts under the budget sends all its requests. The docstring says that the budget "can be passed by the cost of one round per worker". The Service has 14 workers (7 repositories, 2 lanes each), and a round costs 30 to 120 requests, so the budget can be passed by several hundred requests in an hour.
  2. It loses requests. It starts from the count at the time it is made, so requests sent before the budget exists are not in it. A round that is still running when the pod stops never reaches record_round, so its requests are not written to the record that the next pod reads (fix(service): a restart keeps the halt, the budget window and the failure ledger, and a secondary limit or a suspended installation stops every worker #2474). Each merge to main starts a new pod (Argo CD Image Updater, strategy Recreate), and there were 2 restarts in that hour. Telemetry counted about 300 requests more than the record.

The go-live plan stops the Service at more than 600 requests in an hour, because the budget was expected to hold near 500.

Reproduction Steps

  1. Run the Service with 7 repositories and the default budget of 500.
  2. Read sum(increase(devops_cli_github_requests_total{job="roadmap-service"}[1h])), or sum the raw samples of the counter, and compare it with the sum of the last hour in <data dir>/roadmap/service-budget.json.
  3. The telemetry count is above 500, and above the record.

Expected vs Actual Behavior

Expected: the Service sends no more than service.github_requests_per_hour requests in any one hour, across restarts. The check is made for each request where the request is sent (the GitHub rate limiter or the session transport), not at the end of a round. A request that the budget does not allow waits until the window has room, or ends the round. Each sent request is kept in the record when it is sent, so a pod that stops in the middle of a round loses none. A reputable sliding-window limiter, such as the limits package (moving window), is the tool to consider before building one.

Actual: about 913 requests in the hour against a budget of 500, and 614 in the record.

Environment Diagnostics

main at 657b03d and later, pods roadmap-service-9f4d8fd6d-2qwfd, roadmap-service-b89d69c88-k6cj5 and roadmap-service-7cd9cb446d-ns6h2.

Logs, Traces, or Terminal Output

20:50:08 WARNING The Service sent 556 GitHub requests in the last hour, and its budget is 500: no round starts until the window has room.
21:22 telemetry, last hour: core 838, graphql 75 (2 counter resets, one for each new pod)
21:22 service-budget.json, last hour: 614

RoadmapServiceGitHubRequestsHigh fired from 20:45. There were no identity refusals, no rate-limit refusals and no secondary limits from GitHub.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The Service's hourly GitHub budget checks the request count only at round end. It blocks only new rounds from starting. A round that starts under the budget sends all its requests. A round still running when the pod stops never records its requests. The Service sent about 913 requests in one hour against a budget of 500.

Acceptance criteria

  • Criterion 1: The Service sends no more than service.github_requests_per_hour GitHub requests in any one hour, across restarts.
    Verification: Run the Service with 7 repositories and the default budget of 500. Read the telemetry counter for one hour. The count is 500 or less.
  • Criterion 2: The budget check runs for each request at the point the request is sent, not at the end of a round.
    Verification: Read the code. The budget check is in the request send path, not in record_round.
  • Criterion 3: A request the budget does not allow waits until the sliding window has room, or the round ends.
    Verification: Run a test that exhausts the budget. The next request waits. When the window has room, the request proceeds.
  • Criterion 4: Each sent request is written to the budget record file when it is sent.
    Verification: Send one request. Read the record file. The count includes that request.
  • Criterion 5: A pod that stops in the middle of a round loses no requests from the record.
    Verification: Start a round. Stop the pod mid-round. Read the record file. The count includes all requests sent before the stop.

Key questions

  • Where is the budget check made in the request path?: In the GitHub rate limiter, which already intercepts every request and tracks the global count. (best practice) [sources: src/devops_cli/server/service.py]
    • Chosen: GitHub rate limiter. It already intercepts every request and tracks the global count. The existing process_request_count reads from it.
    • Rejected: Session transport. It is lower-level and harder to integrate with the existing budget logic and persistence.
  • Which sliding window algorithm does the budget use?: The existing deque-based moving window in RequestBudget, updated per request instead of per round. (best practice) [sources: src/devops_cli/server/service.py]
    • Chosen: Existing deque-based window. It already implements a correct sliding window with file persistence and thread safety. The fix is the integration point, not the algorithm.
    • Rejected: limits package. It is for per-client HTTP rate limiting. It lacks blocking and file persistence. It adds a dependency for an algorithm the project already has.
  • What happens when a request exceeds the budget?: The request waits until the sliding window has room. If the window does not have room in time, the round ends. (proposed)
    • Chosen: Wait then end round. The issue states the request waits until the window has room, or ends the round.
    • Rejected: Reject the request. Rejecting would lose work. The Service should complete its rounds when possible.
  • When is the budget record file written?: On every request, under the lock, so a pod that stops mid-round loses no requests. (best practice) [sources: src/devops_cli/server/service.py]
    • Chosen: Per request. The issue states each sent request is kept in the record when it is sent. At most 500 writes per hour is low I/O.
    • Rejected: Per round. A round still running when the pod stops never reaches the write. This is the current defect.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/high
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The budget enforces 500/hour but the Service sends 913, which is a defect in the existing enforcement logic.
    • Priority: P1-High. The Service is actively exceeding its budget in production and the go-live plan depends on the limit holding.
    • Value: High. Exceeding the budget risks GitHub rate-limit refusals and service disruption for all users of the roadmap Service.
    • Effort: Medium. Requires changing the check from per-round to per-request in the send path and switching persistence from batch to per-request, possibly adopting the limits package.
    • Related: fix(service): a restart keeps the halt, the budget window and the failure ledger, and a secondary limit or a suspended installation stops every worker #2474, which asks for a different change. Both deal with the budget window surviving a restart, but #2474 persists the halt and window state while this candidate changes enforcement to check at each request send and writes each count immediately.
  3. added
    priority/p1-high
    on Oct 28, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 29, 2026
  5. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at b32348a (see proposed design in issue body).

  6. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

    A threshold of 500 seems arbitrarily low. Increase as needed as long as it honors github api request limits

  7. removed
    status/ready
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions