Skip to content

Commit

Permalink
fix: [TKC-2564] reduce memory pressure (#5858)
Browse files Browse the repository at this point in the history
* fix: postman test

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

* fix: reduce memory pressure

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

---------

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
  • Loading branch information
vsukhin authored Sep 20, 2024
1 parent aa7ef8d commit b900101
Show file tree
Hide file tree
Showing 2 changed files with 49 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
37 changes: 37 additions & 0 deletions test/postman/hello-postman.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"info": {
"_postman_id": "2c19e161-6009-4237-8643-9c6df5b0c596",
"name": "hello-postman",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "549544"
},
"item": [
{
"name": "website-active-check",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function(){",
" pm.response.to.have.status(200);",
"})"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{URL}}",
"host": [
"{{URL}}"
]
}
},
"response": []
}
]
}

0 comments on commit b900101

Please sign in to comment.