fix(sandbox): skip identical skill installs and prune old snapshots - #2791
Merged
Conversation
Re-uploading the same archive of a ready skill was still booting a billed sandbox and growing a new generation. Superceded snapshots also accumulated on the provider because the ledger never deleted them. Skip the rebuild when the digest already matches a skill still in the live image, and let the reaper delete superseded provider snapshots after 24h while leaving extras not in the ledger untouched.
A re-upload of the same archive skipped every installing row, so a dead process could not recover until the reaper. Skip only recent in-flight runs, still refresh the stored bundle, and prune non-live active snapshots after retention.
A fixed window on the submission time cannot tell a slow install from a dead one: a single agent command may take installCommandTimeout and an install runs several of them, so a two-minute window called live runs dead, reset their progress and pushed the reaper's own deadline out. Stamp InstallingSince while the run works and read that instead, which also stops the reaper from failing installs that are merely long. Answer the skip question from the image only for a ready row. The ledger records which skill a snapshot carries, not which archive, so a row installing a new bundle would look finished from the previous bundle's snapshot and report a success that never happened. Prune now refuses to delete once the credentials no longer address the account that built the image: the delete would come back not-found, and the ledger would record another account's still-billed snapshots as gone. It also waits for an eligible row before building a provider client, since most configs have nothing to prune on most sweeps.
Keep the skip/heartbeat install tests and the tenantForStorage tests that landed on main in the same file.
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.
Summary
Test plan
go test ./internal/application/service/ ./internal/sandbox/ ./internal/types/