Repository navigation
Conversation
AdaAibaby
requested review from
ValentaTomas,
dobrac and
jakubno
as code owners
August 18, 2026 02:34
AdaAibaby
force-pushed
the
fix/orchestrator-resource-exhausted-error-context
branch
from
August 18, 2026 03:17
999c1f7 to
8de62ee
Compare
…c that varies Fixes e2b-dev#3583 When a node refuses a sandbox with ResourceExhausted and the API logs "Node exhausted, trying another node", the error string carried no numbers for two of the three sites, and the running-sandboxes one carried only the cap. Operators could not tell a saturated node from a throttled start gate. Add context, choosing per site the value that actually varies at refusal time rather than a tautological "current" (which always equals the cap the moment the gate rejects): - running sandboxes: include max= (the reserve-within cap). current is definitionally == max here, so only the cap is informative. - starting sandboxes (instant TryAcquire): include max= via a new AdjustableSemaphore.Limit() accessor. Same reasoning — a refusal means the gate is full, so the cap is the new information. - resuming sandboxes (blocking Acquire up to acquireTimeout): include waited= and max=. waited is the differentiating value: it separates a hard timeout (gate saturated the whole window) from a fast context cancellation, which current/max cannot show. Only Limit() is added to AdjustableSemaphore; a Current() accessor was dropped because it carries no information a refusal does not already imply. Tests: - resizable_semaphore_limit_test.go: Limit() tracks the initial cap and SetLimit, independent of held slots. - resource_exhausted_message_test.go: the resuming refusal message carries waited= and max= via the real waitForAcquire path. - sandbox_limit_metric_test.go: updated to the new message formats.
AdaAibaby
force-pushed
the
fix/orchestrator-resource-exhausted-error-context
branch
from
November 10, 2026 12:14
8de62ee to
7b80447
Compare
AdaAibaby
force-pushed
the
fix/orchestrator-resource-exhausted-error-context
branch
from
November 25, 2026 14:03
7b80447 to
395969e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3583
Problem
When the orchestrator returns a
ResourceExhaustedgRPC error and the API logs "Node exhausted, trying another node", the attached error string carried no useful numbers. Two of the three sites had no counts at all, and the running-sandboxes one had only the cap:Approach: annotate with the value that actually varies at refusal time
A naive fix adds
current=N, max=Meverywhere. But for the gate sites,currentis tautological: the branch only runs because the gate is full, socurrentalways equalsmax. So each site gets the value that carries real information:max=(the reserve-within cap).currentis definitionally== maxhere, so only the cap is informative.TryAcquire) —max=, via a newAdjustableSemaphore.Limit()accessor. A refusal means the gate is full; the cap is the new information.Acquireup toacquireTimeout) —waited=andmax=.waitedis the differentiating value: it separates a hard timeout (the gate stayed saturated the whole window) from a fast context cancellation — somethingcurrent/maxcannot show.Only
Limit()is added toAdjustableSemaphore; aCurrent()accessor was intentionally dropped because it carries no information a refusal does not already imply.After this change
Changes
packages/shared/pkg/utils/resizable_semaphore.go— addLimit() int64packages/orchestrator/pkg/server/sandboxes.go—max=on the running and starting refusalspackages/orchestrator/pkg/server/utils.go—waited=+max=on the resuming refusalTesting
resizable_semaphore_limit_test.go—Limit()tracks the initial cap andSetLimit, independent of held slots.resource_exhausted_message_test.go— the resuming refusal carrieswaited=andmax=via the realwaitForAcquirepath.sandbox_limit_metric_test.go— updated to the new message formats.go build/go vetclean forpackages/sharedandpackages/orchestrator/pkg/server./cc @ryan-sana @jakubno @dobrac @ValentaTomas @arkamar @tvi Looking forward to your code review.