Skip to content

Commit

Permalink
fix: reduce memory pressure
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
  • Loading branch information
vsukhin committed Sep 19, 2024
1 parent 09772d4 commit 61c3a4b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/storage/minio/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ var _ storage.Client = (*Client)(nil)
// ErrArtifactsNotFound contains error for not existing artifacts
var ErrArtifactsNotFound = errors.New("Execution doesn't have any artifacts associated with it")

// absMinPartSize - absolute minimum part size (5 MiB) below which
// a part in a multipart upload may not be uploaded.
const absMinPartSize = 1024 * 1024 * 5

// Client for managing MinIO storage server
type Client struct {
region string
Expand Down Expand Up @@ -490,8 +494,15 @@ func (c *Client) uploadFile(ctx context.Context, bucket, bucketFolder, filePath
filePath = strings.Trim(bucketFolder, "/") + "/" + filePath
}

var partSize uint64
if objectSize == -1 {
partSize = absMinPartSize
}

c.Log.Debugw("saving object in minio", "file", filePath, "bucket", bucket)
_, err = c.minioClient.PutObject(ctx, bucket, filePath, reader, objectSize, minio.PutObjectOptions{ContentType: "application/octet-stream"})
_, err = c.minioClient.PutObject(ctx, bucket, filePath, reader, objectSize, minio.PutObjectOptions{
ContentType: "application/octet-stream",
PartSize: partSize})
if err != nil {
return fmt.Errorf("minio saving file (%s) put object error: %w", filePath, err)
}
Expand Down

0 comments on commit 61c3a4b

Please sign in to comment.