From 27aa4eec85f2c78946f56a203d387e7cf2ca7159 Mon Sep 17 00:00:00 2001 From: Jonathan Jamroga Date: Fri, 12 Jun 2026 11:20:00 -0400 Subject: [PATCH] Propagate ctx into memorypullcache image pulls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #230. --- internal/memorypullcache/memorypullcache.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/memorypullcache/memorypullcache.go b/internal/memorypullcache/memorypullcache.go index 1da7da664..481db59fb 100644 --- a/internal/memorypullcache/memorypullcache.go +++ b/internal/memorypullcache/memorypullcache.go @@ -121,10 +121,17 @@ func (c *MemoryPullCache) Fetch(ctx context.Context, ref string) (io.ReadCloser, // trips to the registry. var remoteOptions []remote.Option - remoteOptions = append(remoteOptions, remote.WithPlatform(v1.Platform{ - Architecture: runtime.GOARCH, - OS: "linux", - })) + remoteOptions = append(remoteOptions, + // Propagate caller ctx into go-containerregistry so cancellation tears + // down in-flight layer-blob HTTP requests instead of letting them run + // to completion in background goroutines (which retain partial-blob + // buffers and amplify atelet RSS during ResumeActor death loops). + remote.WithContext(ctx), + remote.WithPlatform(v1.Platform{ + Architecture: runtime.GOARCH, + OS: "linux", + }), + ) registry := parsedRef.Context().Registry.RegistryStr() if registry == "gcr.io" || strings.HasSuffix(registry, ".gcr.io") || registry == "pkg.dev" || strings.HasSuffix(registry, ".pkg.dev") {