Skip to content

Commit 569abfa

Browse files
git-hyagidkliban
authored andcommitted
Buffer image layers in chunks in sync upload API
closes: #2081 (cherry picked from commit 2510dd9)
1 parent 6bcce46 commit 569abfa

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGES/2081.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Modified the sync upload API to buffer the image layers in chunks, reducing memory usage.

pulp_container/app/registry_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
from pulp_container.constants import (
9393
EMPTY_BLOB,
9494
MANIFEST_TYPE,
95+
MEGABYTE,
9596
SIGNATURE_API_EXTENSION_VERSION,
9697
SIGNATURE_HEADER,
9798
SIGNATURE_PAYLOAD_MAX_SIZE,
@@ -842,7 +843,8 @@ def create_single_chunk_artifact(self, chunk):
842843
with transaction.atomic():
843844
# 1 chunk, create artifact right away
844845
with NamedTemporaryFile("ab") as temp_file:
845-
temp_file.write(chunk.read())
846+
while subchunk := chunk.read(MEGABYTE):
847+
temp_file.write(subchunk)
846848
temp_file.flush()
847849

848850
uploaded_file = PulpTemporaryUploadedFile.from_file(

0 commit comments

Comments
 (0)