Skip to content

Large GCS uploads no longer leave scratch objects behind - #2178

Merged
Michelle Au (msau42) merged 3 commits into
agent-substrate:mainfrom
ericcurtin:gcs-compose-final-cleanup
Oct 19, 2026
Merged

Michelle Au (msau42) merged 3 commits into
agent-substrate:mainfrom
ericcurtin:gcs-compose-final-cleanup

Conversation

@ericcurtin

Copy link
Copy Markdown
Contributor

Fixes #2154

Large GCS uploads left their last compose intermediates behind. Now removed on return, and the duplicated cleanup is shared.

Test runs against fake-gcs-server.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@ericcurtin

Copy link
Copy Markdown
Contributor Author

ILLUM1N0X Taahir Ahmed (@ahmedtd) PTAL when you get a chance. Thank you!

@maxsmythe

Copy link
Copy Markdown
Collaborator

Michelle Au (@msau42) for triage

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Tim Flannagan (@timflannagan) ktsoator (@ktsoator) PTAL when you get a chance. Thank you!

@ktsoator

Copy link
Copy Markdown
Contributor

Hi, Eric Curtin (@ericcurtin) :)

Ah, I think you might have mentioned the wrong person! I'm not involved with maintaining this repository. Good luck with your PR though!

@ericcurtin

Copy link
Copy Markdown
Contributor Author

ktsoator (@ktsoator) Sorry for the mix-up, and thank you for letting me know.

Michelle Au (@msau42) Zoe Zhao (@zoez7) PTAL when you get a chance. Thank you!

Comment thread pkg/objectstorage/gcscompose.go Outdated
for _, o := range objs {
if delErr := o.Delete(context.WithoutCancel(ctx)); delErr != nil &&
!errors.Is(delErr, storage.ErrObjectNotExist) && err == nil {
err = fmt.Errorf("while removing upload part %q: %w", o.ObjectName(), delErr)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to: "while removing scratch object"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in cc561e9, thanks.

Comment thread pkg/objectstorage/gcscompose_test.go Outdated
// Folding more than maxComposeSources parts goes through intermediate objects, and
// none may outlive the compose, including the ones the final compose consumes.
func TestComposeAllRemovesIntermediates(t *testing.T) {
client, bucket := emulatorClient(t)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 should-fix 🟡 – emulatorClient skips whenever STORAGE_EMULATOR_HOST is unset, and CI never sets it, so this test never runs in CI. composeAll only sends Compose and Delete requests, so you can drive it against an httptest.NewServer (like TestPutObjectRetriesTransient429 in pkg/objectstorage/gcs_retry_test.go:72) and have it run on every go test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in c9136c0.

Comment thread pkg/objectstorage/gcscompose.go Outdated
for _, s := range group {
_ = s.Delete(context.WithoutCancel(ctx))
}
mids = append(mids, mid)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit 🟢 – If Run(ctx) fails on the client after GCS committed mid (such as a timeout or dropped connection on the response), mid is not in mids and leaks. Append mid to mids before calling Run(ctx), matching how putComposite and PutSparseFile register parts before uploading. removeScratch already ignores storage.ErrObjectNotExist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in c9136c0.

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Michelle Au (@msau42) Max Smythe (@maxsmythe) Addressed both notes (c9136c0), PTAL when you get a chance. Thank you!

@msau42
Michelle Au (msau42) added this pull request to the merge queue Oct 19, 2026
Merged via the queue into agent-substrate:main with commit 42e50cd Oct 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage kind/bug Something isn't working / bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete final-round GCS compose inputs after successful uploads

5 participants