Enforce our Minimum Requirements for Node Operators and sanity check them (#2155)
This commit is contained in:
parent
749846b42b
commit
74484fc57e
@ -425,6 +425,9 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
"--kademlia.operator.email", fmt.Sprintf("storage%d@example.com", i),
|
||||
"--kademlia.operator.wallet", "0x0123456789012345678901234567890123456789",
|
||||
|
||||
"--storage2.monitor.minimum-disk-space", "25GB",
|
||||
"--storage2.monitor.minimum-bandwidth", "25GB",
|
||||
|
||||
"--server.extensions.revocation=false",
|
||||
"--server.use-peer-ca-whitelist=false",
|
||||
"--storage.satellite-id-restriction=false",
|
||||
|
@ -53,6 +53,7 @@ import (
|
||||
"storj.io/storj/satellite/vouchers"
|
||||
"storj.io/storj/storagenode"
|
||||
"storj.io/storj/storagenode/collector"
|
||||
"storj.io/storj/storagenode/monitor"
|
||||
"storj.io/storj/storagenode/orders"
|
||||
"storj.io/storj/storagenode/piecestore"
|
||||
"storj.io/storj/storagenode/storagenodedb"
|
||||
@ -619,6 +620,10 @@ func (planet *Planet) newStorageNodes(count int, whitelistedSatelliteIDs []strin
|
||||
Interval: time.Hour,
|
||||
Timeout: time.Hour,
|
||||
},
|
||||
Monitor: monitor.Config{
|
||||
MinimumBandwidth: 100 * memory.MB,
|
||||
MinimumDiskSpace: 100 * memory.MB,
|
||||
},
|
||||
},
|
||||
Version: planet.NewVersionConfig(),
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
"storj.io/storj/internal/memory"
|
||||
"storj.io/storj/internal/sync2"
|
||||
"storj.io/storj/pkg/kademlia"
|
||||
"storj.io/storj/pkg/pb"
|
||||
@ -27,7 +28,9 @@ var (
|
||||
|
||||
// Config defines parameters for storage node disk and bandwidth usage monitoring.
|
||||
type Config struct {
|
||||
Interval time.Duration `help:"how frequently Kademlia bucket should be refreshed with node stats" default:"1h0m0s"`
|
||||
Interval time.Duration `help:"how frequently Kademlia bucket should be refreshed with node stats" default:"1h0m0s"`
|
||||
MinimumDiskSpace memory.Size `help:"how much disk space a node at minimum has to advertise" default:"500GB"`
|
||||
MinimumBandwidth memory.Size `help:"how much bandwidth a node at minimum has to advertise" default:"500GB"`
|
||||
}
|
||||
|
||||
// Service which monitors disk usage and updates kademlia network as necessary.
|
||||
@ -40,12 +43,13 @@ type Service struct {
|
||||
allocatedDiskSpace int64
|
||||
allocatedBandwidth int64
|
||||
Loop sync2.Cycle
|
||||
Config Config
|
||||
}
|
||||
|
||||
// TODO: should it be responsible for monitoring actual bandwidth as well?
|
||||
|
||||
// NewService creates a new storage node monitoring service.
|
||||
func NewService(log *zap.Logger, routingTable *kademlia.RoutingTable, store *pieces.Store, pieceInfo pieces.DB, usageDB bandwidth.DB, allocatedDiskSpace, allocatedBandwidth int64, interval time.Duration) *Service {
|
||||
func NewService(log *zap.Logger, routingTable *kademlia.RoutingTable, store *pieces.Store, pieceInfo pieces.DB, usageDB bandwidth.DB, allocatedDiskSpace, allocatedBandwidth int64, interval time.Duration, config Config) *Service {
|
||||
return &Service{
|
||||
log: log,
|
||||
routingTable: routingTable,
|
||||
@ -55,6 +59,7 @@ func NewService(log *zap.Logger, routingTable *kademlia.RoutingTable, store *pie
|
||||
allocatedDiskSpace: allocatedDiskSpace,
|
||||
allocatedBandwidth: allocatedBandwidth,
|
||||
Loop: *sync2.NewCycle(interval),
|
||||
Config: config,
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,6 +112,18 @@ func (service *Service) Run(ctx context.Context) (err error) {
|
||||
service.log.Warn("Disk space is less than requested. Allocating space", zap.Int64("bytes", service.allocatedDiskSpace))
|
||||
}
|
||||
|
||||
// Ensure the disk is at least 500GB in size, which is our current minimum required to be an operator
|
||||
if service.allocatedDiskSpace < service.Config.MinimumDiskSpace.Int64() {
|
||||
service.log.Error("Total disk space less than required minimum", zap.Int64("bytes", service.Config.MinimumDiskSpace.Int64()))
|
||||
return Error.New("disk space requirement not met")
|
||||
}
|
||||
|
||||
// Ensure the bandwidth is at least 500GB
|
||||
if service.allocatedBandwidth < service.Config.MinimumBandwidth.Int64() {
|
||||
service.log.Error("Total Bandwidth available less than required minimum", zap.Int64("bytes", service.Config.MinimumBandwidth.Int64()))
|
||||
return Error.New("bandwidth requirement not met")
|
||||
}
|
||||
|
||||
return service.Loop.Run(ctx, func(ctx context.Context) error {
|
||||
err := service.updateNodeInformation(ctx)
|
||||
if err != nil {
|
||||
|
@ -213,6 +213,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config Config, ver
|
||||
config.Storage.AllocatedBandwidth.Int64(),
|
||||
//TODO use config.Storage.Monitor.Interval, but for some reason is not set
|
||||
config.Storage.KBucketRefreshInterval,
|
||||
config.Storage2.Monitor,
|
||||
)
|
||||
|
||||
peer.Storage2.Endpoint, err = piecestore.NewEndpoint(
|
||||
|
Loading…
Reference in New Issue
Block a user