Skip to content

fix: stream multipart upload in UploadArtifact to avoid unbounded mem…#372

Open
abhaygoudannavar wants to merge 1 commit into
microcks:masterfrom
abhaygoudannavar:fix/stream-upload-artifact
Open

fix: stream multipart upload in UploadArtifact to avoid unbounded mem…#372
abhaygoudannavar wants to merge 1 commit into
microcks:masterfrom
abhaygoudannavar:fix/stream-upload-artifact

Conversation

@abhaygoudannavar
Copy link
Copy Markdown

Description

  • Replaced in-memory bytes.Buffer with io.Pipe() streaming in UploadArtifact (pkg/connectors/microcks_client.go). Multipart form data is now written in a background goroutine and streamed directly from disk to the HTTP request, keeping memory usage constant regardless of artifact file size.
  • Replaced two panic() calls with proper fmt.Errorf error returns in the upload path, matching the style of recent fixes (e.g., f9f282c).
  • Added TestUploadArtifactStreamsWithoutBuffering test (pkg/connectors/microcks_client_test.go) covering file content integrity, filename, mainArtifact field, and HTTP response handling.

Test results:
$ go test ./pkg/connectors/... ok github.com/microcks/microcks-cli/pkg/connectors 0.022s

Related issue(s)

Fixes #324

…ory allocation

Replace bytes.Buffer with io.Pipe() in UploadArtifact so multipart form
data is streamed directly from disk to the HTTP request. This keeps
memory usage constant regardless of artifact file size, preventing OOM
kills on constrained CI/CD runners.

Also replaces panic() calls with proper error returns in the upload path.

Fixes microcks#324

Signed-off-by: abhaygoudannavar <abhaysgoudnvr@gmail.com>
@abhaygoudannavar
Copy link
Copy Markdown
Author

@Harsh4902 i worked on #324 any changes is needed in the pr?

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.

Unbounded memory allocation in UploadArtifact due to in-memory multipart buffering

1 participant