Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move list quorum ENV to config #10804

Merged
merged 2 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions cmd/config/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ const (
apiClusterDeadline = "cluster_deadline"
apiCorsAllowOrigin = "cors_allow_origin"
apiRemoteTransportDeadline = "remote_transport_deadline"
apiListQuorum = "list_quorum"

EnvAPIRequestsMax = "MINIO_API_REQUESTS_MAX"
EnvAPIRequestsDeadline = "MINIO_API_REQUESTS_DEADLINE"
EnvAPIClusterDeadline = "MINIO_API_CLUSTER_DEADLINE"
EnvAPICorsAllowOrigin = "MINIO_API_CORS_ALLOW_ORIGIN"
EnvAPIRemoteTransportDeadline = "MINIO_API_REMOTE_TRANSPORT_DEADLINE"
EnvAPIListQuorum = "MINIO_API_LIST_QUORUM"
EnvAPISecureCiphers = "MINIO_API_SECURE_CIPHERS"
)

// Deprecated key and ENVs
Expand Down Expand Up @@ -71,6 +74,10 @@ var (
Key: apiRemoteTransportDeadline,
Value: "2h",
},
config.KV{
Key: apiListQuorum,
Value: "optimal",
},
}
)

Expand All @@ -81,6 +88,7 @@ type Config struct {
ClusterDeadline time.Duration `json:"cluster_deadline"`
CorsAllowOrigin []string `json:"cors_allow_origin"`
RemoteTransportDeadline time.Duration `json:"remote_transport_deadline"`
ListQuorum string `json:"list_strict_quorum"`
}

// UnmarshalJSON - Validate SS and RRS parity when unmarshalling JSON.
Expand All @@ -94,6 +102,24 @@ func (sCfg *Config) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &aux)
}

// GetListQuorum interprets list quorum values and returns appropriate
// acceptable quorum expected for list operations
func (sCfg Config) GetListQuorum() int {
switch sCfg.ListQuorum {
case "optimal":
return 3
case "reduced":
return 2
case "disk":
// smallest possible value, generally meant for testing.
return 1
case "strict":
return -1
}
// Defaults to 3 drives per set.
return 3
}

// LookupConfig - lookup api config and override with valid environment settings if any.
func LookupConfig(kvs config.KVS) (cfg Config, err error) {
// remove this since we have removed this already.
Expand Down Expand Up @@ -130,11 +156,19 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
return cfg, err
}

listQuorum := env.Get(EnvAPIListQuorum, kvs.Get(apiListQuorum))
switch listQuorum {
case "strict", "optimal", "reduced", "disk":
default:
return cfg, errors.New("invalid value for list strict quorum")
}

return Config{
RequestsMax: requestsMax,
RequestsDeadline: requestsDeadline,
ClusterDeadline: clusterDeadline,
CorsAllowOrigin: corsAllowOrigin,
RemoteTransportDeadline: remoteTransportDeadline,
ListQuorum: listQuorum,
}, nil
}
6 changes: 6 additions & 0 deletions cmd/config/storageclass/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ var (
Optional: true,
Type: "string",
},
config.HelpKV{
Key: ClassDMA,
Description: `enable O_DIRECT for both read and write, defaults to "write" e.g. "read+write"`,
Optional: true,
Type: "string",
},
config.HelpKV{
Key: config.Comment,
Description: config.DefaultComment,
Expand Down
4 changes: 2 additions & 2 deletions cmd/config/storageclass/storage-class.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const (
// DMA storage class
DMA = "DMA"

// Valid values are "write" and "read-write"
// Valid values are "write" and "read+write"
DMAWrite = "write"
DMAReadWrite = "read-write"
DMAReadWrite = "read+write"
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
)

// Standard constats for config info storage class
Expand Down
8 changes: 5 additions & 3 deletions cmd/erasure-server-sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,10 +1340,12 @@ func (z *erasureServerSets) Walk(ctx context.Context, bucket, prefix string, res

serverSetsListTolerancePerSet := make([]int, 0, len(z.serverSets))
for _, zone := range z.serverSets {
if zone.listTolerancePerSet == -1 {
quorum := globalAPIConfig.getListQuorum()
switch quorum {
case -1:
serverSetsListTolerancePerSet = append(serverSetsListTolerancePerSet, zone.setDriveCount/2)
} else {
serverSetsListTolerancePerSet = append(serverSetsListTolerancePerSet, zone.listTolerancePerSet-2)
default:
serverSetsListTolerancePerSet = append(serverSetsListTolerancePerSet, quorum)
}
}

Expand Down
42 changes: 16 additions & 26 deletions cmd/erasure-sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ import (
"github.com/dchest/siphash"
"github.com/google/uuid"
"github.com/minio/minio-go/v7/pkg/tags"
"github.com/minio/minio/cmd/config"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/bpool"
"github.com/minio/minio/pkg/dsync"
"github.com/minio/minio/pkg/env"
"github.com/minio/minio/pkg/madmin"
"github.com/minio/minio/pkg/sync/errgroup"
)
Expand Down Expand Up @@ -81,7 +79,6 @@ type erasureSets struct {

// Total number of sets and the number of disks per set.
setCount, setDriveCount int
listTolerancePerSet int

disksConnectEvent chan diskConnectInfo

Expand Down Expand Up @@ -345,31 +342,24 @@ func newErasureSets(ctx context.Context, endpoints Endpoints, storageDisks []Sto

endpointStrings := make([]string, len(endpoints))

listTolerancePerSet := 3
// By default this is off
if env.Get("MINIO_API_LIST_STRICT_QUORUM", config.EnableOn) == config.EnableOn {
listTolerancePerSet = -1
}

// Initialize the erasure sets instance.
s := &erasureSets{
sets: make([]*erasureObjects, setCount),
erasureDisks: make([][]StorageAPI, setCount),
erasureLockers: make([][]dsync.NetLocker, setCount),
erasureLockOwner: GetLocalPeer(globalEndpoints),
endpoints: endpoints,
endpointStrings: endpointStrings,
setCount: setCount,
setDriveCount: setDriveCount,
listTolerancePerSet: listTolerancePerSet,
format: format,
disksConnectEvent: make(chan diskConnectInfo),
distributionAlgo: format.Erasure.DistributionAlgo,
deploymentID: uuid.MustParse(format.ID),
pool: NewMergeWalkPool(globalMergeLookupTimeout),
poolSplunk: NewMergeWalkPool(globalMergeLookupTimeout),
poolVersions: NewMergeWalkVersionsPool(globalMergeLookupTimeout),
mrfOperations: make(map[healSource]int),
sets: make([]*erasureObjects, setCount),
erasureDisks: make([][]StorageAPI, setCount),
erasureLockers: make([][]dsync.NetLocker, setCount),
erasureLockOwner: GetLocalPeer(globalEndpoints),
endpoints: endpoints,
endpointStrings: endpointStrings,
setCount: setCount,
setDriveCount: setDriveCount,
format: format,
disksConnectEvent: make(chan diskConnectInfo),
distributionAlgo: format.Erasure.DistributionAlgo,
deploymentID: uuid.MustParse(format.ID),
pool: NewMergeWalkPool(globalMergeLookupTimeout),
poolSplunk: NewMergeWalkPool(globalMergeLookupTimeout),
poolVersions: NewMergeWalkVersionsPool(globalMergeLookupTimeout),
mrfOperations: make(map[healSource]int),
}

mutex := newNSLock(globalIsDistErasure)
Expand Down
2 changes: 1 addition & 1 deletion cmd/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ var (
globalBucketTargetSys *BucketTargetSys
// globalAPIConfig controls S3 API requests throttling,
// healthcheck readiness deadlines and cors settings.
globalAPIConfig apiConfig
globalAPIConfig = apiConfig{listQuorum: 3}

globalStorageClass storageclass.Config
globalLDAPConfig xldap.Config
Expand Down
9 changes: 9 additions & 0 deletions cmd/handler-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type apiConfig struct {
requestsDeadline time.Duration
requestsPool chan struct{}
clusterDeadline time.Duration
listQuorum int
corsAllowOrigins []string
}

Expand Down Expand Up @@ -63,6 +64,14 @@ func (t *apiConfig) init(cfg api.Config, setDriveCount int) {

t.requestsPool = make(chan struct{}, apiRequestsMaxPerNode)
t.requestsDeadline = cfg.RequestsDeadline
t.listQuorum = cfg.GetListQuorum()
}

func (t *apiConfig) getListQuorum() int {
t.mu.RLock()
defer t.mu.RUnlock()

return t.listQuorum
}

func (t *apiConfig) getCorsAllowOrigins() []string {
Expand Down
7 changes: 2 additions & 5 deletions cmd/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/minio/minio-go/v7/pkg/set"
"github.com/minio/minio/cmd/config"
"github.com/minio/minio/cmd/config/api"
"github.com/minio/minio/pkg/certs"
"github.com/minio/minio/pkg/env"
)
Expand Down Expand Up @@ -180,13 +181,9 @@ var secureCipherSuites = []uint16{
// Go only provides constant-time implementations of Curve25519 and NIST P-256 curve.
var secureCurves = []tls.CurveID{tls.X25519, tls.CurveP256}

const (
enableSecureCiphersEnv = "MINIO_API_SECURE_CIPHERS"
)

// NewServer - creates new HTTP server using given arguments.
func NewServer(addrs []string, handler http.Handler, getCert certs.GetCertificateFunc) *Server {
secureCiphers := env.Get(enableSecureCiphersEnv, config.EnableOn) == config.EnableOn
secureCiphers := env.Get(api.EnvAPISecureCiphers, config.EnableOn) == config.EnableOn

var tlsConfig *tls.Config
if getCert != nil {
Expand Down
17 changes: 1 addition & 16 deletions cmd/metacache-server-sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import (
"path"
"sync"

"github.com/minio/minio/cmd/config"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/env"
)

// listPath will return the requested entries.
Expand Down Expand Up @@ -119,20 +117,7 @@ func (z *erasureServerSets) listPath(ctx context.Context, o listPathOptions) (en
}

if o.AskDisks == 0 {
switch env.Get("MINIO_API_LIST_STRICT_QUORUM", config.EnableOff) {
case config.EnableOn:
// If strict, ask at least 50%.
o.AskDisks = -1
case "reduced":
// Reduced safety.
o.AskDisks = 2
case "disk":
// Ask single disk.
o.AskDisks = 1
default:
// By default asks at max 3 disks.
o.AskDisks = 3
}
o.AskDisks = globalAPIConfig.getListQuorum()
}

var mu sync.Mutex
Expand Down