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