b2d342aa9b
Create global config to specify a list of country codes that should be excluded from node selection during uploads. This exclusion is not implemented when the upload selection cache is disabled. Change-Id: Ic41e8b4f18857a11045668eac23107da99668a72
69 lines
3.0 KiB
Go
69 lines
3.0 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package overlay
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/spacemonkeygo/monkit/v3"
|
|
"github.com/zeebo/errs"
|
|
|
|
"storj.io/common/memory"
|
|
)
|
|
|
|
var (
|
|
mon = monkit.Package()
|
|
// Error represents an overlay error.
|
|
Error = errs.Class("overlay")
|
|
)
|
|
|
|
// Config is a configuration for overlay service.
|
|
type Config struct {
|
|
Node NodeSelectionConfig
|
|
NodeSelectionCache UploadSelectionCacheConfig
|
|
GeoIP GeoIPConfig
|
|
UpdateStatsBatchSize int `help:"number of update requests to process per transaction" default:"100"`
|
|
NodeCheckInWaitPeriod time.Duration `help:"the amount of time to wait before accepting a redundant check-in from a node (unmodified info since last check-in)" default:"2h" testDefault:"30s"`
|
|
RepairExcludedCountryCodes []string `help:"list of country codes to exclude nodes from target repair selection" default:"" testDefault:"FR,BE"`
|
|
}
|
|
|
|
// AsOfSystemTimeConfig is a configuration struct to enable 'AS OF SYSTEM TIME' for CRDB queries.
|
|
type AsOfSystemTimeConfig struct {
|
|
Enabled bool `help:"enables the use of the AS OF SYSTEM TIME feature in CRDB" default:"true"`
|
|
DefaultInterval time.Duration `help:"default duration for AS OF SYSTEM TIME" devDefault:"-1ms" releaseDefault:"-10s" testDefault:"-1µs"`
|
|
}
|
|
|
|
// NodeSelectionConfig is a configuration struct to determine the minimum
|
|
// values for nodes to select.
|
|
type NodeSelectionConfig struct {
|
|
NewNodeFraction float64 `help:"the fraction of new nodes allowed per request" releaseDefault:"0.05" devDefault:"1"`
|
|
MinimumVersion string `help:"the minimum node software version for node selection queries" default:""`
|
|
OnlineWindow time.Duration `help:"the amount of time without seeing a node before its considered offline" default:"4h" testDefault:"1m"`
|
|
DistinctIP bool `help:"require distinct IPs when choosing nodes for upload" releaseDefault:"true" devDefault:"false"`
|
|
MinimumDiskSpace memory.Size `help:"how much disk space a node at minimum must have to be selected for upload" default:"500.00MB" testDefault:"100.00MB"`
|
|
|
|
AsOfSystemTime AsOfSystemTimeConfig
|
|
|
|
UploadExcludedCountryCodes []string `help:"list of country codes to exclude from node selection for uploads" default:"" testDefault:"FR,BE"`
|
|
}
|
|
|
|
// GeoIPConfig is a configuration struct that helps configure the GeoIP lookup features on the satellite.
|
|
type GeoIPConfig struct {
|
|
DB string `help:"the location of the maxmind database containing geoip country information"`
|
|
MockCountries []string `help:"a mock list of countries the satellite will attribute to nodes (useful for testing)"`
|
|
}
|
|
|
|
func (aost *AsOfSystemTimeConfig) isValid() error {
|
|
if aost.Enabled {
|
|
if aost.DefaultInterval >= 0 {
|
|
return errs.New("AS OF SYSTEM TIME interval must be a negative number")
|
|
}
|
|
if aost.DefaultInterval > -time.Microsecond {
|
|
return errs.New("AS OF SYSTEM TIME interval cannot be in nanoseconds")
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|