Add WithFileBufferedOpener for file-backed daemon image buffering#2214
Add WithFileBufferedOpener for file-backed daemon image buffering#2214Subserial merged 9 commits intogoogle:mainfrom
Conversation
|
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. |
74c1471 to
3e5903b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2214 +/- ##
===========================================
- Coverage 71.67% 53.17% -18.51%
===========================================
Files 123 164 +41
Lines 9935 10977 +1042
===========================================
- Hits 7121 5837 -1284
- Misses 2115 4433 +2318
- Partials 699 707 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Added a #nosec comment to suppress security warning for file creation.
|
Sorry about the gosec churn, we just updated our linter and it came with new features. |
8913260 to
dcfe77d
Compare
|
@Subserial thanks for the approval. Next it is saying |
Yeah, I have to come back and approve the test run. Once the one goimports error is fixed I should be able to merge the PR. |
Thanks. I have removed the unused import. |
Summary
WithFileBufferedOpener()option todaemon.Image()that buffers the docker save stream to a temp file instead of memorySee: kubernetes/minikube#17785
See: kubernetes/minikube#21103
How it works
daemon.Image()currently has two modes:io.ReadAllinto[]byte— one save, but full image in RAMImageSaveon every access — low memory but O(N) savesThis adds a third mode:
io.Copyto temp file — one save, ~32KB peak memoryCleanup
The temp file is automatically cleaned up via
runtime.AddCleanupon theimageOpener— no explicit close needed. If the GC doesn't run before process exit, the file sits inos.TempDir()until OS cleanup.Benchmark (
elasticsearch:9.0.3, 1.47GB)Run with
/usr/bin/time -vusing the includedbench_memory_test.go(-tags bench_memory):10.9x memory reduction.
Test plan
-tags bench_memory)