fix: maxConcurrent '0' is an invalid value (#15500)

log and continue with defaults instead of
crashing the service.
This commit is contained in:
Harshavardhana 2022-08-08 15:18:45 -07:00 committed by GitHub
parent 6a6c772ff2
commit ecdc2f2f5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -23,7 +23,6 @@ import (
"fmt"
"io"
"math/rand"
"os"
"strconv"
"strings"
"sync"
@ -32,6 +31,7 @@ import (
"github.com/minio/madmin-go"
"github.com/minio/minio/internal/logger"
"github.com/minio/pkg/env"
)
//go:generate stringer -type=storageMetric -trimprefix=storageMetric $GOFILE
@ -575,12 +575,11 @@ const (
var diskMaxConcurrent = 512
func init() {
if s, ok := os.LookupEnv("_MINIO_DISK_MAX_CONCURRENT"); ok && s != "" {
var err error
diskMaxConcurrent, err = strconv.Atoi(s)
if err != nil {
logger.Fatal(err, "invalid _MINIO_DISK_MAX_CONCURRENT value")
}
s := env.Get("_MINIO_DISK_MAX_CONCURRENT", "512")
diskMaxConcurrent, _ = strconv.Atoi(s)
if diskMaxConcurrent <= 0 {
logger.LogIf(GlobalContext, fmt.Errorf("invalid _MINIO_DISK_MAX_CONCURRENT value: %s, defaulting to '512'", s))
diskMaxConcurrent = 512
}
}