Skip to content

feat(webapp): gate worker dequeues by worker queue via env var#4030

Draft
ericallam wants to merge 1 commit into
mainfrom
feat/worker-queue-dequeue-gate
Draft

feat(webapp): gate worker dequeues by worker queue via env var#4030
ericallam wants to merge 1 commit into
mainfrom
feat/worker-queue-dequeue-gate

Conversation

@ericallam

@ericallam ericallam commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Adds a RUN_ENGINE_DEQUEUE_DISABLED_WORKER_QUEUES setting that refuses worker dequeue requests for the listed worker queues (or base regions), so their runs stay queued instead of being handed to workers that can't run them. Blocked dequeues are counted via a run_engine.dequeue.blocked OTel counter (labeled by worker_queue and region).

Add RUN_ENGINE_DEQUEUE_DISABLED_WORKER_QUEUES: a comma-separated list of
worker queues (or base regions, which also cover the :scheduled split) for
which the engine API refuses worker dequeue requests and returns no work, so
those runs stay queued instead of being handed to workers that cannot run
them. Unset means no gating. Blocked dequeues increment the
run_engine.dequeue.blocked otel counter, tagged by worker_queue and region.
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

A new dequeue gate is added for the webapp's run engine. An optional environment variable RUN_ENGINE_DEQUEUE_DISABLED_WORKER_QUEUES is registered in EnvironmentSchema. Two helpers, parseDisabledWorkerQueues and matchesDisabledWorkerQueue, are added to workerQueueSplit.server.ts to parse the CSV value into a set and test whether a given queue (or its base region) is in that set. A new dequeueGate.server.ts module uses these helpers and a tracing counter (run_engine.dequeue.blocked) to expose isWorkerQueueDequeueDisabled and recordBlockedDequeue. In workerGroupTokenService.server.ts, AuthenticatedWorkerInstance.dequeue is updated to check the gate and return an empty array when dequeuing is disabled for the computed worker queue.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description only includes a Summary and omits the template's required issue, checklist, testing, changelog, and screenshots sections. Add the missing template sections, including the closing issue reference, checklist items, testing steps, changelog, and screenshots or indicate none.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific, concise, and matches the main change: gating worker dequeues with an env var.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/worker-queue-dequeue-gate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant