Skip to content

Propagate ctx into memorypullcache image pulls - #231

Merged
Bowei Du (bowei) merged 1 commit into
agent-substrate:mainfrom
jjamroga:jjamroga/fix-image-pull-context-leak
Jun 12, 2026
Merged

Bowei Du (bowei) merged 1 commit into
agent-substrate:mainfrom
jjamroga:jjamroga/fix-image-pull-context-leak

Conversation

@jjamroga

Copy link
Copy Markdown
Collaborator

Fixes #230.

Summary

remote.Image in internal/memorypullcache/memorypullcache.go was being called without remote.WithContext, so cancellation of the caller's ctx (e.g. when ActorWorkflow.ResumeActor hits its 28s deadline at cmd/ateapi/internal/controlapi/workflow.go:145) did not stop the in-flight layer-blob HTTP requests. The goroutines kept running until the TCP connection was torn down, retaining partial-blob buffers in the meantime.

On a death loop of ResumeActor retries against a large image, this amplifies atelet RSS proportionally to the loop duration — observed peaking at ~9.4GB on a kind node where baseline atelet was ~2.4GB, enough to OOM atelet on tight production workers and take every other actor on that worker down with it.

This PR only addresses the leak (Bug B in #230). The 28s workflow-deadline bug (Bug A) — which is what produces the death loops in the first place — is a separate, larger change and will land in a follow-up PR.

Test plan

  • go test ./internal/memorypullcache/... -count=1 — 29 passed
  • go vet ./... — clean
  • go build ./... — clean
  • Manual repro from bin/repro.md shows atelet RSS no longer climbs during the death loop (TODO: rerun on this branch and attach a before/after RSS chart in a follow-up comment)

remote.Image was being called without remote.WithContext, so cancellation
of the workflow ctx (e.g. when ActorWorkflow.ResumeActor hits its 28s
deadline) did not stop the in-flight layer-blob HTTP requests. The
goroutines kept running until the TCP connection was torn down,
retaining partial-blob buffers in the meantime.

On a death loop of ResumeActor retries against a large image, this
amplifies atelet RSS proportionally to the loop duration — observed
peaking at ~9.4GB on a kind node where baseline atelet was ~2.4GB,
enough to OOM atelet on tight production workers.

Fixes agent-substrate#230.
@google-cla

google-cla Bot commented Jun 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jjamroga

Copy link
Copy Markdown
Collaborator Author

googlebot I signed it!

1 similar comment
@jjamroga

Copy link
Copy Markdown
Collaborator Author

googlebot I signed it!

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.

Large image pulls death-loop in ResumeActor and amplify atelet RSS

2 participants