worker: allow configuring number of upload threads for Azure

The default number of threads (16) is OK for general use case. However,
we are being asked by RH IT to lower the number of threads when
uploading the image to Azure using proxy server.

Make the number of threads configurable in the worker configuration and
default to the currently used value if it is not provided.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2023-03-03 14:35:36 +01:00 committed by Tomáš Hozza
parent a08eb69b2e
commit 0e4a5b34b2
4 changed files with 40 additions and 9 deletions

View file

@ -1,9 +1,11 @@
package main
import (
"fmt"
"os"
"github.com/BurntSushi/toml"
"github.com/osbuild/osbuild-composer/internal/upload/azure"
"github.com/sirupsen/logrus"
)
@ -27,7 +29,8 @@ type gcpConfig struct {
}
type azureConfig struct {
Credentials string `toml:"credentials"`
Credentials string `toml:"credentials"`
UploadThreads int `toml:"upload_threads"`
}
type awsConfig struct {
@ -90,5 +93,14 @@ func parseConfig(file string) (*workerConfig, error) {
logrus.Info("Configuration file not found, using defaults")
}
// set defaults for Azure only if the config section is present
if config.Azure != nil {
if config.Azure.UploadThreads == 0 {
config.Azure.UploadThreads = azure.DefaultUploadThreads
} else if config.Azure.UploadThreads < 0 {
return nil, fmt.Errorf("invalid number of Azure upload threads: %d", config.Azure.UploadThreads)
}
}
return &config, nil
}