[langfun/env] Suspend and resume sandbox services across backend outages. - #754
Open
copybara-service[bot] wants to merge 1 commit into
Open
[langfun/env] Suspend and resume sandbox services across backend outages.#754copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
…ges.
A sandbox service that depends on a remote backend had no recovery path when
that backend went away:
* The errors raised while connecting to a backend are typically neither
`EnvironmentError` nor `SandboxStateError`, so they escaped the outage
retry loop of `BaseSandboxService` and crashed the hosting process.
* Once an outage outlasted `outage_grace_period`, the service called the
terminal `shutdown()`. `acquire()` then kept raising
`SandboxServiceOutageError` for the rest of the process lifetime, even
after the backend came back, while the process itself stayed up.
`BaseSandboxService` now:
* exposes a `transient_outage_errors` hook, so a backend-specific subclass
can declare the errors it raises while establishing its connection. Those
errors enter the existing outage retry loop, which remains bounded by
`outage_grace_period`.
* adds `Status.SUSPENDED` plus a `suspend()` / `_resume()` pair. Giving up
past the grace period now releases all resources but leaves the service
resumable, and the next `acquire()` brings it back into service with a
fresh outage budget. If the backend is still unreachable, the service
falls back to `SUSPENDED` so that a later `acquire()` can try again.
`shutdown()` stays terminal.
A suspended service still reports `is_online == False`, so readiness signals
are unchanged.
PiperOrigin-RevId: 964499236
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.
[langfun/env] Suspend and resume sandbox services across backend outages.
A sandbox service that depends on a remote backend had no recovery path when
that backend went away:
EnvironmentErrornorSandboxStateError, so they escaped the outageretry loop of
BaseSandboxServiceand crashed the hosting process.outage_grace_period, the service called theterminal
shutdown().acquire()then kept raisingSandboxServiceOutageErrorfor the rest of the process lifetime, evenafter the backend came back, while the process itself stayed up.
BaseSandboxServicenow:transient_outage_errorshook, so a backend-specific subclasscan declare the errors it raises while establishing its connection. Those
errors enter the existing outage retry loop, which remains bounded by
outage_grace_period.Status.SUSPENDEDplus asuspend()/_resume()pair. Giving uppast the grace period now releases all resources but leaves the service
resumable, and the next
acquire()brings it back into service with afresh outage budget. If the backend is still unreachable, the service
falls back to
SUSPENDEDso that a lateracquire()can try again.shutdown()stays terminal.A suspended service still reports
is_online == False, so readiness signalsare unchanged.