2019-06-21 14:39:43 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information
|
|
|
|
|
|
|
|
package testplanet
|
|
|
|
|
|
|
|
import (
|
2019-10-14 21:01:53 +01:00
|
|
|
"context"
|
|
|
|
"net"
|
2019-06-21 14:39:43 +01:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
|
2019-08-19 23:10:38 +01:00
|
|
|
"github.com/zeebo/errs"
|
2019-10-14 21:01:53 +01:00
|
|
|
"go.uber.org/zap"
|
|
|
|
"golang.org/x/sync/errgroup"
|
2019-08-19 23:10:38 +01:00
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/errs2"
|
|
|
|
"storj.io/common/identity"
|
|
|
|
"storj.io/common/memory"
|
|
|
|
"storj.io/common/peertls/extensions"
|
|
|
|
"storj.io/common/peertls/tlsopts"
|
|
|
|
"storj.io/common/rpc"
|
|
|
|
"storj.io/common/storj"
|
2020-05-19 11:21:56 +01:00
|
|
|
"storj.io/common/uuid"
|
2020-03-23 19:18:20 +00:00
|
|
|
"storj.io/private/debug"
|
2020-03-23 19:30:31 +00:00
|
|
|
"storj.io/private/version"
|
2020-05-19 11:21:56 +01:00
|
|
|
"storj.io/storj/pkg/auth"
|
2019-08-19 23:10:38 +01:00
|
|
|
"storj.io/storj/pkg/revocation"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/pkg/server"
|
2019-11-14 19:46:15 +00:00
|
|
|
versionchecker "storj.io/storj/private/version/checker"
|
2020-04-08 20:40:49 +01:00
|
|
|
"storj.io/storj/private/web"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/satellite"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/accounting"
|
|
|
|
"storj.io/storj/satellite/accounting/live"
|
2020-07-07 15:48:09 +01:00
|
|
|
"storj.io/storj/satellite/accounting/projectbwcleanup"
|
2020-01-15 21:45:17 +00:00
|
|
|
"storj.io/storj/satellite/accounting/reportedrollup"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/accounting/rollup"
|
|
|
|
"storj.io/storj/satellite/accounting/tally"
|
2020-02-07 16:36:28 +00:00
|
|
|
"storj.io/storj/satellite/admin"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/audit"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/satellite/console"
|
|
|
|
"storj.io/storj/satellite/console/consoleweb"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/contact"
|
2019-08-27 18:12:38 +01:00
|
|
|
"storj.io/storj/satellite/dbcleanup"
|
2019-12-30 19:42:10 +00:00
|
|
|
"storj.io/storj/satellite/downtime"
|
2019-07-24 18:26:43 +01:00
|
|
|
"storj.io/storj/satellite/gc"
|
2019-10-07 21:38:05 +01:00
|
|
|
"storj.io/storj/satellite/gracefulexit"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/inspector"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/satellite/mailservice"
|
2019-06-24 21:51:54 +01:00
|
|
|
"storj.io/storj/satellite/marketingweb"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/satellite/metainfo"
|
2020-04-15 20:20:16 +01:00
|
|
|
"storj.io/storj/satellite/metainfo/expireddeletion"
|
2020-07-09 16:32:35 +01:00
|
|
|
"storj.io/storj/satellite/metainfo/objectdeletion"
|
2020-03-12 07:03:46 +00:00
|
|
|
"storj.io/storj/satellite/metainfo/piecedeletion"
|
2019-10-16 19:08:33 +01:00
|
|
|
"storj.io/storj/satellite/metrics"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/nodestats"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/satellite/orders"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/overlay"
|
2020-05-18 10:17:05 +01:00
|
|
|
"storj.io/storj/satellite/payments/paymentsconfig"
|
|
|
|
"storj.io/storj/satellite/payments/stripecoinpayments"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/repair/checker"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/repair/irreparable"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/repair/repairer"
|
2020-03-27 16:18:19 +00:00
|
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
2019-10-31 17:27:38 +00:00
|
|
|
"storj.io/storj/storage/redis/redisserver"
|
2019-06-21 14:39:43 +01:00
|
|
|
)
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// Satellite contains all the processes needed to run a full Satellite setup.
|
2020-03-27 14:46:40 +00:00
|
|
|
type Satellite struct {
|
|
|
|
Config satellite.Config
|
|
|
|
|
2019-11-04 19:01:02 +00:00
|
|
|
Core *satellite.Core
|
2019-10-29 14:55:57 +00:00
|
|
|
API *satellite.API
|
|
|
|
Repairer *satellite.Repairer
|
2020-02-07 15:56:59 +00:00
|
|
|
Admin *satellite.Admin
|
2020-03-12 15:40:22 +00:00
|
|
|
GC *satellite.GarbageCollection
|
2019-10-14 21:01:53 +01:00
|
|
|
|
|
|
|
Log *zap.Logger
|
|
|
|
Identity *identity.FullIdentity
|
|
|
|
DB satellite.DB
|
|
|
|
|
|
|
|
Dialer rpc.Dialer
|
|
|
|
|
|
|
|
Server *server.Server
|
|
|
|
|
2019-10-21 11:50:59 +01:00
|
|
|
Version *versionchecker.Service
|
2019-10-14 21:01:53 +01:00
|
|
|
|
|
|
|
Contact struct {
|
|
|
|
Service *contact.Service
|
|
|
|
Endpoint *contact.Endpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
Overlay struct {
|
|
|
|
DB overlay.DB
|
|
|
|
Service *overlay.Service
|
|
|
|
Inspector *overlay.Inspector
|
|
|
|
}
|
|
|
|
|
|
|
|
Metainfo struct {
|
|
|
|
Database metainfo.PointerDB
|
|
|
|
Service *metainfo.Service
|
|
|
|
Endpoint2 *metainfo.Endpoint
|
|
|
|
Loop *metainfo.Loop
|
|
|
|
}
|
|
|
|
|
|
|
|
Inspector struct {
|
|
|
|
Endpoint *inspector.Endpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
Orders struct {
|
2020-01-10 18:53:42 +00:00
|
|
|
DB orders.DB
|
2019-10-14 21:01:53 +01:00
|
|
|
Endpoint *orders.Endpoint
|
|
|
|
Service *orders.Service
|
2020-01-10 18:53:42 +00:00
|
|
|
Chore *orders.Chore
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Repair struct {
|
|
|
|
Checker *checker.Checker
|
|
|
|
Repairer *repairer.Service
|
|
|
|
Inspector *irreparable.Inspector
|
|
|
|
}
|
|
|
|
Audit struct {
|
|
|
|
Queue *audit.Queue
|
|
|
|
Worker *audit.Worker
|
|
|
|
Chore *audit.Chore
|
|
|
|
Verifier *audit.Verifier
|
|
|
|
Reporter *audit.Reporter
|
|
|
|
}
|
|
|
|
|
|
|
|
GarbageCollection struct {
|
|
|
|
Service *gc.Service
|
|
|
|
}
|
|
|
|
|
2020-04-15 20:20:16 +01:00
|
|
|
ExpiredDeletion struct {
|
|
|
|
Chore *expireddeletion.Chore
|
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
DBCleanup struct {
|
|
|
|
Chore *dbcleanup.Chore
|
|
|
|
}
|
|
|
|
|
|
|
|
Accounting struct {
|
2020-07-07 15:48:09 +01:00
|
|
|
Tally *tally.Service
|
|
|
|
Rollup *rollup.Service
|
|
|
|
ProjectUsage *accounting.Service
|
|
|
|
ReportedRollup *reportedrollup.Chore
|
|
|
|
ProjectBWCleanup *projectbwcleanup.Chore
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LiveAccounting struct {
|
2019-10-16 17:50:29 +01:00
|
|
|
Cache accounting.Cache
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Mail struct {
|
|
|
|
Service *mailservice.Service
|
|
|
|
}
|
|
|
|
|
|
|
|
Console struct {
|
|
|
|
Listener net.Listener
|
|
|
|
Service *console.Service
|
|
|
|
Endpoint *consoleweb.Server
|
|
|
|
}
|
|
|
|
|
|
|
|
Marketing struct {
|
|
|
|
Listener net.Listener
|
|
|
|
Endpoint *marketingweb.Server
|
|
|
|
}
|
|
|
|
|
|
|
|
NodeStats struct {
|
|
|
|
Endpoint *nodestats.Endpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
GracefulExit struct {
|
|
|
|
Chore *gracefulexit.Chore
|
|
|
|
Endpoint *gracefulexit.Endpoint
|
|
|
|
}
|
2019-10-16 19:08:33 +01:00
|
|
|
|
|
|
|
Metrics struct {
|
|
|
|
Chore *metrics.Chore
|
|
|
|
}
|
2019-12-30 19:42:10 +00:00
|
|
|
|
|
|
|
DowntimeTracking struct {
|
2020-01-07 21:34:48 +00:00
|
|
|
DetectionChore *downtime.DetectionChore
|
|
|
|
EstimationChore *downtime.EstimationChore
|
|
|
|
Service *downtime.Service
|
2019-12-30 19:42:10 +00:00
|
|
|
}
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns the ID of the Satellite system.
|
2020-03-27 14:46:40 +00:00
|
|
|
func (system *Satellite) ID() storj.NodeID { return system.API.Identity.ID }
|
2019-10-14 21:01:53 +01:00
|
|
|
|
|
|
|
// Addr returns the public address from the Satellite system API.
|
2020-03-27 14:46:40 +00:00
|
|
|
func (system *Satellite) Addr() string { return system.API.Server.Addr().String() }
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2020-04-16 13:12:46 +01:00
|
|
|
// URL returns the node url from the Satellite system API.
|
|
|
|
func (system *Satellite) URL() string { return system.NodeURL().String() }
|
|
|
|
|
|
|
|
// NodeURL returns the storj.NodeURL from the Satellite system API.
|
|
|
|
func (system *Satellite) NodeURL() storj.NodeURL {
|
2019-10-14 21:01:53 +01:00
|
|
|
return storj.NodeURL{ID: system.API.ID(), Address: system.API.Addr()}
|
|
|
|
}
|
|
|
|
|
2020-07-24 10:40:17 +01:00
|
|
|
// AddUser adds user to a satellite. Password from newUser will be always overridden by FullName to have
|
|
|
|
// known password which can be used automatically.
|
|
|
|
func (system *Satellite) AddUser(ctx context.Context, newUser console.CreateUser, maxNumberOfProjects int) (*console.User, error) {
|
2020-05-19 11:21:56 +01:00
|
|
|
regToken, err := system.API.Console.Service.CreateRegToken(ctx, maxNumberOfProjects)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-07-24 10:40:17 +01:00
|
|
|
newUser.Password = newUser.FullName
|
|
|
|
user, err := system.API.Console.Service.CreateUser(ctx, newUser, regToken.Secret, "")
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
activationToken, err := system.API.Console.Service.GenerateActivationToken(ctx, user.ID, user.Email)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = system.API.Console.Service.ActivateAccount(ctx, activationToken)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-07-24 10:40:17 +01:00
|
|
|
authCtx, err := system.AuthenticatedContext(ctx, user.ID)
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = system.API.Console.Service.Payments().SetupAccount(authCtx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return user, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddProject adds project to a satellite and makes specified user an owner.
|
|
|
|
func (system *Satellite) AddProject(ctx context.Context, ownerID uuid.UUID, name string) (*console.Project, error) {
|
2020-07-24 10:40:17 +01:00
|
|
|
authCtx, err := system.AuthenticatedContext(ctx, ownerID)
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
project, err := system.API.Console.Service.CreateProject(authCtx, console.ProjectInfo{
|
|
|
|
Name: name,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return project, nil
|
|
|
|
}
|
|
|
|
|
2020-07-24 10:40:17 +01:00
|
|
|
// AuthenticatedContext creates context with authentication date for given user.
|
|
|
|
func (system *Satellite) AuthenticatedContext(ctx context.Context, userID uuid.UUID) (context.Context, error) {
|
2020-05-19 11:21:56 +01:00
|
|
|
user, err := system.API.Console.Service.GetUser(ctx, userID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// we are using full name as a password
|
|
|
|
token, err := system.API.Console.Service.Token(ctx, user.Email, user.FullName)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
auth, err := system.API.Console.Service.Authorize(auth.WithAPIKey(ctx, []byte(token)))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return console.WithAuth(ctx, auth), nil
|
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// Close closes all the subsystems in the Satellite system.
|
2020-03-27 14:46:40 +00:00
|
|
|
func (system *Satellite) Close() error {
|
2020-02-07 16:36:28 +00:00
|
|
|
return errs.Combine(
|
|
|
|
system.API.Close(),
|
|
|
|
system.Core.Close(),
|
|
|
|
system.Repairer.Close(),
|
|
|
|
system.Admin.Close(),
|
2020-03-12 15:40:22 +00:00
|
|
|
system.GC.Close(),
|
2020-02-07 16:36:28 +00:00
|
|
|
)
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// Run runs all the subsystems in the Satellite system.
|
2020-03-27 14:46:40 +00:00
|
|
|
func (system *Satellite) Run(ctx context.Context) (err error) {
|
2019-10-14 21:01:53 +01:00
|
|
|
group, ctx := errgroup.WithContext(ctx)
|
|
|
|
|
|
|
|
group.Go(func() error {
|
2019-11-04 19:01:02 +00:00
|
|
|
return errs2.IgnoreCanceled(system.Core.Run(ctx))
|
2019-10-14 21:01:53 +01:00
|
|
|
})
|
|
|
|
group.Go(func() error {
|
|
|
|
return errs2.IgnoreCanceled(system.API.Run(ctx))
|
|
|
|
})
|
2019-10-29 14:55:57 +00:00
|
|
|
group.Go(func() error {
|
|
|
|
return errs2.IgnoreCanceled(system.Repairer.Run(ctx))
|
|
|
|
})
|
2020-02-07 16:36:28 +00:00
|
|
|
group.Go(func() error {
|
|
|
|
return errs2.IgnoreCanceled(system.Admin.Run(ctx))
|
|
|
|
})
|
2020-03-12 15:40:22 +00:00
|
|
|
group.Go(func() error {
|
|
|
|
return errs2.IgnoreCanceled(system.GC.Run(ctx))
|
|
|
|
})
|
2019-10-14 21:01:53 +01:00
|
|
|
return group.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrivateAddr returns the private address from the Satellite system API.
|
2020-03-27 14:46:40 +00:00
|
|
|
func (system *Satellite) PrivateAddr() string { return system.API.Server.PrivateAddr().String() }
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// newSatellites initializes satellites.
|
2020-03-27 16:18:19 +00:00
|
|
|
func (planet *Planet) newSatellites(count int, satelliteDatabases satellitedbtest.SatelliteDatabases) ([]*Satellite, error) {
|
2020-03-27 14:46:40 +00:00
|
|
|
var xs []*Satellite
|
2019-06-21 14:39:43 +01:00
|
|
|
defer func() {
|
|
|
|
for _, x := range xs {
|
2019-12-16 16:00:57 +00:00
|
|
|
planet.peers = append(planet.peers, newClosablePeer(x))
|
2019-06-21 14:39:43 +01:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
prefix := "satellite" + strconv.Itoa(i)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
|
|
|
storageDir := filepath.Join(planet.directory, prefix)
|
|
|
|
if err := os.MkdirAll(storageDir, 0700); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
identity, err := planet.NewIdentity()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:18:19 +00:00
|
|
|
db, err := satellitedbtest.CreateMasterDB(context.TODO(), log.Named("db"), planet.config.Name, "S", i, satelliteDatabases.MasterDB)
|
2019-06-21 14:39:43 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:18:19 +00:00
|
|
|
if planet.config.Reconfigure.SatelliteDB != nil {
|
|
|
|
var newdb satellite.DB
|
|
|
|
newdb, err = planet.config.Reconfigure.SatelliteDB(log.Named("db"), i, db)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, db.Close())
|
|
|
|
}
|
|
|
|
db = newdb
|
2019-10-10 19:06:26 +01:00
|
|
|
}
|
2020-03-27 16:18:19 +00:00
|
|
|
planet.databases = append(planet.databases, db)
|
|
|
|
|
|
|
|
pointerDB, err := satellitedbtest.CreatePointerDB(context.TODO(), log.Named("pointerdb"), planet.config.Name, "P", i, satelliteDatabases.PointerDB)
|
2019-10-10 19:06:26 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-03-27 16:18:19 +00:00
|
|
|
|
|
|
|
if planet.config.Reconfigure.SatellitePointerDB != nil {
|
|
|
|
var newPointerDB metainfo.PointerDB
|
|
|
|
newPointerDB, err = planet.config.Reconfigure.SatellitePointerDB(log.Named("pointerdb"), i, pointerDB)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, pointerDB.Close())
|
|
|
|
}
|
|
|
|
pointerDB = newPointerDB
|
|
|
|
}
|
2020-01-23 22:17:23 +00:00
|
|
|
planet.databases = append(planet.databases, pointerDB)
|
2019-10-10 19:06:26 +01:00
|
|
|
|
2020-01-31 18:28:42 +00:00
|
|
|
redis, err := redisserver.Mini()
|
2019-10-31 17:27:38 +00:00
|
|
|
if err != nil {
|
2020-01-31 18:28:42 +00:00
|
|
|
return nil, err
|
2019-10-31 17:27:38 +00:00
|
|
|
}
|
2020-01-31 18:28:42 +00:00
|
|
|
planet.databases = append(planet.databases, redis)
|
2019-10-31 17:27:38 +00:00
|
|
|
|
2019-06-21 14:39:43 +01:00
|
|
|
config := satellite.Config{
|
|
|
|
Server: server.Config{
|
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
PrivateAddress: "127.0.0.1:0",
|
|
|
|
|
|
|
|
Config: tlsopts.Config{
|
|
|
|
RevocationDBURL: "bolt://" + filepath.Join(storageDir, "revocation.db"),
|
|
|
|
UsePeerCAWhitelist: true,
|
|
|
|
PeerCAWhitelistPath: planet.whitelistPath,
|
|
|
|
PeerIDVersions: "latest",
|
|
|
|
Extensions: extensions.Config{
|
|
|
|
Revocation: false,
|
|
|
|
WhitelistSignedLeaf: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-01-28 17:35:45 +00:00
|
|
|
Debug: debug.Config{
|
|
|
|
Address: "",
|
|
|
|
},
|
2020-02-07 16:36:28 +00:00
|
|
|
Admin: admin.Config{
|
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
},
|
2020-04-02 21:44:51 +01:00
|
|
|
Contact: contact.Config{
|
|
|
|
Timeout: 1 * time.Minute,
|
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
Overlay: overlay.Config{
|
|
|
|
Node: overlay.NodeSelectionConfig{
|
2020-03-18 21:16:13 +00:00
|
|
|
UptimeCount: 0,
|
|
|
|
AuditCount: 0,
|
|
|
|
NewNodeFraction: 0,
|
|
|
|
OnlineWindow: time.Minute,
|
|
|
|
DistinctIP: false,
|
|
|
|
MinimumDiskSpace: 100 * memory.MB,
|
2019-06-21 14:39:43 +01:00
|
|
|
|
2020-01-03 00:00:18 +00:00
|
|
|
AuditReputationRepairWeight: 1,
|
|
|
|
AuditReputationUplinkWeight: 1,
|
|
|
|
AuditReputationLambda: 0.95,
|
|
|
|
AuditReputationWeight: 1,
|
|
|
|
AuditReputationDQ: 0.6,
|
2020-04-14 17:49:45 +01:00
|
|
|
SuspensionGracePeriod: time.Hour,
|
2020-05-04 17:32:06 +01:00
|
|
|
SuspensionDQEnabled: true,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
2020-04-24 17:11:04 +01:00
|
|
|
NodeSelectionCache: overlay.CacheConfig{
|
|
|
|
Staleness: 3 * time.Minute,
|
|
|
|
},
|
2019-07-31 18:21:06 +01:00
|
|
|
UpdateStatsBatchSize: 100,
|
2020-07-24 22:21:25 +01:00
|
|
|
AuditHistory: overlay.AuditHistoryConfig{
|
|
|
|
WindowSize: 10 * time.Minute,
|
|
|
|
TrackingPeriod: time.Hour,
|
|
|
|
GracePeriod: time.Hour,
|
|
|
|
OfflineThreshold: 0.6,
|
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
|
|
|
Metainfo: metainfo.Config{
|
2019-10-10 19:06:26 +01:00
|
|
|
DatabaseURL: "", // not used
|
|
|
|
MinRemoteSegmentSize: 0, // TODO: fix tests to work with 1024
|
2020-04-01 10:15:24 +01:00
|
|
|
MaxInlineSegmentSize: 4 * memory.KiB,
|
|
|
|
MaxSegmentSize: 64 * memory.MiB,
|
2020-06-01 21:07:31 +01:00
|
|
|
MaxMetadataSize: 2 * memory.KiB,
|
2019-10-01 17:55:02 +01:00
|
|
|
MaxCommitInterval: 1 * time.Hour,
|
2019-06-21 14:39:43 +01:00
|
|
|
Overlay: true,
|
2019-06-21 19:15:58 +01:00
|
|
|
RS: metainfo.RSConfig{
|
2020-01-21 10:38:41 +00:00
|
|
|
MaxBufferMem: memory.Size(256),
|
|
|
|
ErasureShareSize: memory.Size(256),
|
|
|
|
MinThreshold: atLeastOne(planet.config.StorageNodeCount * 1 / 5),
|
|
|
|
RepairThreshold: atLeastOne(planet.config.StorageNodeCount * 2 / 5),
|
|
|
|
SuccessThreshold: atLeastOne(planet.config.StorageNodeCount * 3 / 5),
|
|
|
|
TotalThreshold: atLeastOne(planet.config.StorageNodeCount * 4 / 5),
|
|
|
|
|
2019-10-31 19:04:33 +00:00
|
|
|
MinTotalThreshold: (planet.config.StorageNodeCount * 4 / 5),
|
|
|
|
MaxTotalThreshold: (planet.config.StorageNodeCount * 4 / 5),
|
|
|
|
Validate: false,
|
2019-06-21 19:15:58 +01:00
|
|
|
},
|
2019-07-22 14:34:12 +01:00
|
|
|
Loop: metainfo.LoopConfig{
|
2019-09-11 23:15:14 +01:00
|
|
|
CoalesceDuration: 1 * time.Second,
|
2020-05-05 07:51:24 +01:00
|
|
|
ListLimit: 10000,
|
2019-07-22 14:34:12 +01:00
|
|
|
},
|
2020-01-17 15:01:36 +00:00
|
|
|
RateLimiter: metainfo.RateLimiterConfig{
|
2020-01-29 15:22:22 +00:00
|
|
|
Enabled: true,
|
|
|
|
Rate: 1000,
|
|
|
|
CacheCapacity: 100,
|
|
|
|
CacheExpiration: 10 * time.Second,
|
2020-01-17 15:01:36 +00:00
|
|
|
},
|
2020-06-30 22:49:29 +01:00
|
|
|
ProjectLimits: metainfo.ProjectLimitConfig{
|
|
|
|
MaxBuckets: 1000,
|
|
|
|
DefaultMaxUsage: 25 * memory.GB,
|
|
|
|
DefaultMaxBandwidth: 25 * memory.GB,
|
|
|
|
},
|
2020-03-12 07:03:46 +00:00
|
|
|
PieceDeletion: piecedeletion.Config{
|
2020-08-17 19:49:44 +01:00
|
|
|
MaxConcurrency: 100,
|
|
|
|
MaxConcurrentPieces: 1000,
|
2020-03-12 07:03:46 +00:00
|
|
|
|
|
|
|
MaxPiecesPerBatch: 4000,
|
|
|
|
MaxPiecesPerRequest: 2000,
|
|
|
|
|
|
|
|
DialTimeout: 2 * time.Second,
|
|
|
|
RequestTimeout: 2 * time.Second,
|
|
|
|
FailThreshold: 2 * time.Second,
|
2020-02-13 20:42:19 +00:00
|
|
|
},
|
2020-07-09 16:32:35 +01:00
|
|
|
ObjectDeletion: objectdeletion.Config{
|
|
|
|
MaxObjectsPerRequest: 100,
|
|
|
|
ZombieSegmentsPerRequest: 3,
|
2020-08-17 19:49:44 +01:00
|
|
|
MaxConcurrentRequests: 100,
|
2020-07-09 16:32:35 +01:00
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
|
|
|
Orders: orders.Config{
|
satellite/orders: 3-phase rollout
This adds a config flag orders.window-endpoint-rollout-phase
that can take on the values phase1, phase2 or phase3.
In phase1, the current orders endpoint continues to work as
usual, and the windowed orders endpoint uses the same backend
as the current one (but also does a bit extra).
In phase2, the current orders endpoint is disabled and the
windowed orders endpoint continues to use the same backend.
In phase3, the current orders endpoint is still disabled and
the windowed orders endpoint uses the new backend that requires
much less database traffic and state.
The intention is to deploy in phase1, roll out code to nodes
to have them use the windowed endpoint, switch to phase2, wait
a couple days for all existing orders to expire, then switch
to phase3.
Additionally, it fixes a bug where a node could submit a bunch
of orders and rack up charges for a bucket.
Change-Id: Ifdc10e09ae1645159cbec7ace687dcb2d594c76d
2020-07-21 17:53:32 +01:00
|
|
|
Expiration: 7 * 24 * time.Hour,
|
|
|
|
SettlementBatchSize: 10,
|
|
|
|
FlushBatchSize: 10,
|
|
|
|
FlushInterval: defaultInterval,
|
|
|
|
NodeStatusLogging: true,
|
|
|
|
WindowEndpointRolloutPhase: orders.WindowEndpointRolloutPhase1,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
|
|
|
Checker: checker.Config{
|
2019-09-25 16:41:24 +01:00
|
|
|
Interval: defaultInterval,
|
|
|
|
IrreparableInterval: defaultInterval,
|
|
|
|
ReliabilityCacheStaleness: 1 * time.Minute,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
2020-05-18 10:17:05 +01:00
|
|
|
Payments: paymentsconfig.Config{
|
|
|
|
StorageTBPrice: "10",
|
|
|
|
EgressTBPrice: "45",
|
|
|
|
ObjectPrice: "0.0000022",
|
|
|
|
StripeCoinPayments: stripecoinpayments.Config{
|
|
|
|
TransactionUpdateInterval: defaultInterval,
|
|
|
|
AccountBalanceUpdateInterval: defaultInterval,
|
|
|
|
ConversionRatesCycleInterval: defaultInterval,
|
2020-05-19 08:42:07 +01:00
|
|
|
ListingLimit: 100,
|
2020-05-18 10:17:05 +01:00
|
|
|
},
|
2020-07-10 14:05:17 +01:00
|
|
|
CouponDuration: 2,
|
|
|
|
CouponValue: 275,
|
|
|
|
PaywallProportion: 1,
|
2020-05-18 10:17:05 +01:00
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
Repairer: repairer.Config{
|
2019-07-11 23:44:47 +01:00
|
|
|
MaxRepair: 10,
|
2019-12-20 14:33:47 +00:00
|
|
|
Interval: defaultInterval,
|
2019-07-11 23:44:47 +01:00
|
|
|
Timeout: 1 * time.Minute, // Repairs can take up to 10 seconds. Leaving room for outliers
|
2019-10-30 20:31:08 +00:00
|
|
|
DownloadTimeout: 1 * time.Minute,
|
2020-01-08 18:33:15 +00:00
|
|
|
TotalTimeout: 10 * time.Minute,
|
2019-07-11 23:44:47 +01:00
|
|
|
MaxBufferMem: 4 * memory.MiB,
|
|
|
|
MaxExcessRateOptimalThreshold: 0.05,
|
2020-03-18 23:55:09 +00:00
|
|
|
InMemoryRepair: false,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
|
|
|
Audit: audit.Config{
|
2019-07-03 15:49:08 +01:00
|
|
|
MaxRetriesStatDB: 0,
|
|
|
|
MinBytesPerSecond: 1 * memory.KB,
|
|
|
|
MinDownloadTimeout: 5 * time.Second,
|
2019-09-05 16:40:52 +01:00
|
|
|
MaxReverifyCount: 3,
|
2019-09-25 16:41:24 +01:00
|
|
|
ChoreInterval: defaultInterval,
|
|
|
|
QueueInterval: defaultInterval,
|
2019-09-05 16:40:52 +01:00
|
|
|
Slots: 3,
|
2020-06-26 16:44:25 +01:00
|
|
|
WorkerConcurrency: 2,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
2019-07-24 18:26:43 +01:00
|
|
|
GarbageCollection: gc.Config{
|
2019-09-25 16:41:24 +01:00
|
|
|
Interval: defaultInterval,
|
2019-07-24 18:26:43 +01:00
|
|
|
Enabled: true,
|
|
|
|
InitialPieces: 10,
|
|
|
|
FalsePositiveRate: 0.1,
|
|
|
|
ConcurrentSends: 1,
|
2020-03-26 18:44:18 +00:00
|
|
|
RunInCore: false,
|
2019-07-24 18:26:43 +01:00
|
|
|
},
|
2020-04-15 20:20:16 +01:00
|
|
|
ExpiredDeletion: expireddeletion.Config{
|
|
|
|
Interval: defaultInterval,
|
|
|
|
Enabled: true,
|
|
|
|
},
|
2019-08-27 18:12:38 +01:00
|
|
|
DBCleanup: dbcleanup.Config{
|
2019-09-25 16:41:24 +01:00
|
|
|
SerialsInterval: defaultInterval,
|
2019-08-27 18:12:38 +01:00
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
Tally: tally.Config{
|
2019-09-25 16:41:24 +01:00
|
|
|
Interval: defaultInterval,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
|
|
|
Rollup: rollup.Config{
|
2020-07-16 16:40:29 +01:00
|
|
|
Interval: defaultInterval,
|
|
|
|
DeleteTallies: false,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
2020-01-15 21:45:17 +00:00
|
|
|
ReportedRollup: reportedrollup.Config{
|
|
|
|
Interval: defaultInterval,
|
|
|
|
},
|
2020-07-07 15:48:09 +01:00
|
|
|
ProjectBWCleanup: projectbwcleanup.Config{
|
|
|
|
Interval: defaultInterval,
|
|
|
|
RetainMonths: 1,
|
|
|
|
},
|
2019-10-31 17:27:38 +00:00
|
|
|
LiveAccounting: live.Config{
|
2020-06-02 00:19:10 +01:00
|
|
|
StorageBackend: "redis://" + redis.Addr() + "?db=0",
|
|
|
|
BandwidthCacheTTL: 5 * time.Minute,
|
2019-10-31 17:27:38 +00:00
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
Mail: mailservice.Config{
|
|
|
|
SMTPServerAddress: "smtp.mail.test:587",
|
|
|
|
From: "Labs <storj@mail.test>",
|
|
|
|
AuthType: "simulate",
|
|
|
|
TemplatePath: filepath.Join(developmentRoot, "web/satellite/static/emails"),
|
|
|
|
},
|
|
|
|
Console: consoleweb.Config{
|
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
StaticDir: filepath.Join(developmentRoot, "web/satellite"),
|
2020-02-07 17:24:58 +00:00
|
|
|
AuthToken: "very-secret-token",
|
2019-06-21 14:39:43 +01:00
|
|
|
AuthTokenSecret: "my-suppa-secret-key",
|
2020-03-11 15:36:55 +00:00
|
|
|
Config: console.Config{
|
2020-07-16 16:40:29 +01:00
|
|
|
PasswordCost: console.TestPasswordCost,
|
2020-07-15 17:49:37 +01:00
|
|
|
DefaultProjectLimit: 5,
|
2020-03-11 15:36:55 +00:00
|
|
|
},
|
2020-04-08 20:40:49 +01:00
|
|
|
RateLimit: web.IPRateLimiterConfig{
|
|
|
|
Duration: 5 * time.Minute,
|
|
|
|
Burst: 3,
|
|
|
|
NumLimits: 10,
|
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
|
|
|
Marketing: marketingweb.Config{
|
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
StaticDir: filepath.Join(developmentRoot, "web/marketing"),
|
|
|
|
},
|
|
|
|
Version: planet.NewVersionConfig(),
|
2019-10-07 21:38:05 +01:00
|
|
|
GracefulExit: gracefulexit.Config{
|
2019-11-01 14:21:24 +00:00
|
|
|
Enabled: true,
|
|
|
|
|
2019-10-07 21:38:05 +01:00
|
|
|
ChoreBatchSize: 10,
|
|
|
|
ChoreInterval: defaultInterval,
|
2019-10-11 22:18:05 +01:00
|
|
|
|
2019-10-24 17:24:42 +01:00
|
|
|
EndpointBatchSize: 100,
|
|
|
|
MaxFailuresPerPiece: 5,
|
|
|
|
MaxInactiveTimeFrame: time.Second * 10,
|
|
|
|
OverallMaxFailuresPercentage: 10,
|
2019-10-30 17:40:57 +00:00
|
|
|
RecvTimeout: time.Minute * 1,
|
2019-11-13 14:54:50 +00:00
|
|
|
MaxOrderLimitSendCount: 3,
|
2019-12-20 21:51:13 +00:00
|
|
|
NodeMinAgeInMonths: 0,
|
2019-10-07 21:38:05 +01:00
|
|
|
},
|
2019-10-16 19:08:33 +01:00
|
|
|
Metrics: metrics.Config{
|
|
|
|
ChoreInterval: defaultInterval,
|
|
|
|
},
|
2020-01-02 20:41:18 +00:00
|
|
|
Downtime: downtime.Config{
|
2020-04-13 19:08:04 +01:00
|
|
|
DetectionInterval: defaultInterval,
|
|
|
|
EstimationInterval: defaultInterval,
|
|
|
|
EstimationBatchSize: 5,
|
|
|
|
EstimationConcurrencyLimit: 5,
|
2020-01-02 20:41:18 +00:00
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
}
|
2019-11-21 22:34:49 +00:00
|
|
|
|
|
|
|
if planet.ReferralManager != nil {
|
|
|
|
config.Referrals.ReferralManagerURL = storj.NodeURL{
|
|
|
|
ID: planet.ReferralManager.Identity().ID,
|
|
|
|
Address: planet.ReferralManager.Addr().String(),
|
|
|
|
}
|
|
|
|
}
|
2019-06-21 14:39:43 +01:00
|
|
|
if planet.config.Reconfigure.Satellite != nil {
|
|
|
|
planet.config.Reconfigure.Satellite(log, i, &config)
|
|
|
|
}
|
|
|
|
|
2019-08-22 12:40:15 +01:00
|
|
|
versionInfo := planet.NewVersionInfo()
|
2019-06-21 14:39:43 +01:00
|
|
|
|
2019-08-20 16:04:17 +01:00
|
|
|
revocationDB, err := revocation.NewDBFromCfg(config.Server.Config)
|
2019-08-19 23:10:38 +01:00
|
|
|
if err != nil {
|
2019-08-20 16:04:17 +01:00
|
|
|
return xs, errs.Wrap(err)
|
2019-08-19 23:10:38 +01:00
|
|
|
}
|
2019-10-16 17:50:29 +01:00
|
|
|
|
2019-08-20 16:04:17 +01:00
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
2019-08-19 23:10:38 +01:00
|
|
|
|
2019-12-17 18:18:33 +00:00
|
|
|
liveAccounting, err := live.NewCache(log.Named("live-accounting"), config.LiveAccounting)
|
2019-10-16 17:50:29 +01:00
|
|
|
if err != nil {
|
|
|
|
return xs, errs.Wrap(err)
|
|
|
|
}
|
2019-12-17 18:18:33 +00:00
|
|
|
planet.databases = append(planet.databases, liveAccounting)
|
2019-10-16 17:50:29 +01:00
|
|
|
|
2020-01-17 22:55:53 +00:00
|
|
|
rollupsWriteCache := orders.NewRollupsWriteCache(log.Named("orders-write-cache"), db.Orders(), config.Orders.FlushBatchSize)
|
|
|
|
planet.databases = append(planet.databases, rollupsWriteCacheCloser{rollupsWriteCache})
|
|
|
|
|
2020-05-12 20:10:32 +01:00
|
|
|
peer, err := satellite.New(log, identity, db, pointerDB, revocationDB, liveAccounting, rollupsWriteCache, versionInfo, &config, nil)
|
2019-06-21 14:39:43 +01:00
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
|
|
|
|
2020-04-30 07:36:59 +01:00
|
|
|
err = db.TestingMigrateToLatest(context.TODO())
|
2019-08-20 16:04:17 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
api, err := planet.newAPI(i, identity, db, pointerDB, config, versionInfo)
|
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
2019-10-29 14:55:57 +00:00
|
|
|
|
2020-07-06 22:33:27 +01:00
|
|
|
adminPeer, err := planet.newAdmin(i, identity, db, config, versionInfo)
|
2020-02-07 15:56:59 +00:00
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
|
|
|
|
2019-10-29 14:55:57 +00:00
|
|
|
repairerPeer, err := planet.newRepairer(i, identity, db, pointerDB, config, versionInfo)
|
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
|
|
|
|
2020-03-12 15:40:22 +00:00
|
|
|
gcPeer, err := planet.newGarbageCollection(i, identity, db, pointerDB, config, versionInfo)
|
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
log.Debug("id=" + peer.ID().String() + " addr=" + api.Addr())
|
2019-09-17 21:14:49 +01:00
|
|
|
|
2020-03-27 14:46:40 +00:00
|
|
|
system := createNewSystem(log, config, peer, api, repairerPeer, adminPeer, gcPeer)
|
2019-10-14 21:01:53 +01:00
|
|
|
xs = append(xs, system)
|
2019-06-21 14:39:43 +01:00
|
|
|
}
|
|
|
|
return xs, nil
|
|
|
|
}
|
2019-10-14 21:01:53 +01:00
|
|
|
|
|
|
|
// createNewSystem makes a new Satellite System and exposes the same interface from
|
|
|
|
// before we split out the API. In the short term this will help keep all the tests passing
|
|
|
|
// without much modification needed. However long term, we probably want to rework this
|
|
|
|
// so it represents how the satellite will run when it is made up of many prrocesses.
|
2020-03-27 14:46:40 +00:00
|
|
|
func createNewSystem(log *zap.Logger, config satellite.Config, peer *satellite.Core, api *satellite.API, repairerPeer *satellite.Repairer, adminPeer *satellite.Admin, gcPeer *satellite.GarbageCollection) *Satellite {
|
|
|
|
system := &Satellite{
|
|
|
|
Config: config,
|
2019-11-04 19:01:02 +00:00
|
|
|
Core: peer,
|
2019-10-29 14:55:57 +00:00
|
|
|
API: api,
|
|
|
|
Repairer: repairerPeer,
|
2020-02-07 15:56:59 +00:00
|
|
|
Admin: adminPeer,
|
2020-03-12 15:40:22 +00:00
|
|
|
GC: gcPeer,
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
system.Log = log
|
|
|
|
system.Identity = peer.Identity
|
|
|
|
system.DB = api.DB
|
|
|
|
|
|
|
|
system.Dialer = api.Dialer
|
|
|
|
|
|
|
|
system.Contact.Service = api.Contact.Service
|
|
|
|
system.Contact.Endpoint = api.Contact.Endpoint
|
|
|
|
|
|
|
|
system.Overlay.DB = api.Overlay.DB
|
|
|
|
system.Overlay.Service = api.Overlay.Service
|
|
|
|
system.Overlay.Inspector = api.Overlay.Inspector
|
|
|
|
|
|
|
|
system.Metainfo.Database = api.Metainfo.Database
|
|
|
|
system.Metainfo.Service = peer.Metainfo.Service
|
|
|
|
system.Metainfo.Endpoint2 = api.Metainfo.Endpoint2
|
|
|
|
system.Metainfo.Loop = peer.Metainfo.Loop
|
|
|
|
|
|
|
|
system.Inspector.Endpoint = api.Inspector.Endpoint
|
|
|
|
|
2020-01-10 18:53:42 +00:00
|
|
|
system.Orders.DB = api.Orders.DB
|
2019-10-14 21:01:53 +01:00
|
|
|
system.Orders.Endpoint = api.Orders.Endpoint
|
|
|
|
system.Orders.Service = peer.Orders.Service
|
2020-01-10 18:53:42 +00:00
|
|
|
system.Orders.Chore = api.Orders.Chore
|
2019-10-14 21:01:53 +01:00
|
|
|
|
|
|
|
system.Repair.Checker = peer.Repair.Checker
|
2019-10-29 14:55:57 +00:00
|
|
|
system.Repair.Repairer = repairerPeer.Repairer
|
2019-10-14 21:01:53 +01:00
|
|
|
system.Repair.Inspector = api.Repair.Inspector
|
|
|
|
|
|
|
|
system.Audit.Queue = peer.Audit.Queue
|
|
|
|
system.Audit.Worker = peer.Audit.Worker
|
|
|
|
system.Audit.Chore = peer.Audit.Chore
|
|
|
|
system.Audit.Verifier = peer.Audit.Verifier
|
|
|
|
system.Audit.Reporter = peer.Audit.Reporter
|
|
|
|
|
2020-03-12 15:40:22 +00:00
|
|
|
system.GarbageCollection.Service = gcPeer.GarbageCollection.Service
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2020-04-15 20:20:16 +01:00
|
|
|
system.ExpiredDeletion.Chore = peer.ExpiredDeletion.Chore
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
system.DBCleanup.Chore = peer.DBCleanup.Chore
|
|
|
|
|
|
|
|
system.Accounting.Tally = peer.Accounting.Tally
|
|
|
|
system.Accounting.Rollup = peer.Accounting.Rollup
|
|
|
|
system.Accounting.ProjectUsage = peer.Accounting.ProjectUsage
|
2020-01-15 21:45:17 +00:00
|
|
|
system.Accounting.ReportedRollup = peer.Accounting.ReportedRollupChore
|
2020-07-07 15:48:09 +01:00
|
|
|
system.Accounting.ProjectBWCleanup = peer.Accounting.ProjectBWCleanupChore
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2020-01-31 18:28:42 +00:00
|
|
|
system.LiveAccounting = peer.LiveAccounting
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
system.Marketing.Listener = api.Marketing.Listener
|
|
|
|
system.Marketing.Endpoint = api.Marketing.Endpoint
|
|
|
|
|
|
|
|
system.GracefulExit.Chore = peer.GracefulExit.Chore
|
|
|
|
system.GracefulExit.Endpoint = api.GracefulExit.Endpoint
|
2019-10-16 19:08:33 +01:00
|
|
|
|
|
|
|
system.Metrics.Chore = peer.Metrics.Chore
|
|
|
|
|
2020-01-02 20:41:18 +00:00
|
|
|
system.DowntimeTracking.DetectionChore = peer.DowntimeTracking.DetectionChore
|
2020-01-07 21:34:48 +00:00
|
|
|
system.DowntimeTracking.EstimationChore = peer.DowntimeTracking.EstimationChore
|
2019-12-30 19:42:10 +00:00
|
|
|
system.DowntimeTracking.Service = peer.DowntimeTracking.Service
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
return system
|
|
|
|
}
|
|
|
|
|
|
|
|
func (planet *Planet) newAPI(count int, identity *identity.FullIdentity, db satellite.DB, pointerDB metainfo.PointerDB, config satellite.Config, versionInfo version.Info) (*satellite.API, error) {
|
|
|
|
prefix := "satellite-api" + strconv.Itoa(count)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
var err error
|
|
|
|
|
|
|
|
revocationDB, err := revocation.NewDBFromCfg(config.Server.Config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
|
|
|
|
2019-10-16 17:50:29 +01:00
|
|
|
liveAccounting, err := live.NewCache(log.Named("live-accounting"), config.LiveAccounting)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, liveAccounting)
|
|
|
|
|
2020-01-17 22:55:53 +00:00
|
|
|
rollupsWriteCache := orders.NewRollupsWriteCache(log.Named("orders-write-cache"), db.Orders(), config.Orders.FlushBatchSize)
|
|
|
|
planet.databases = append(planet.databases, rollupsWriteCacheCloser{rollupsWriteCache})
|
|
|
|
|
2020-05-12 20:10:32 +01:00
|
|
|
return satellite.NewAPI(log, identity, db, pointerDB, revocationDB, liveAccounting, rollupsWriteCache, &config, versionInfo, nil)
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
2019-10-29 14:55:57 +00:00
|
|
|
|
2020-07-06 22:33:27 +01:00
|
|
|
func (planet *Planet) newAdmin(count int, identity *identity.FullIdentity, db satellite.DB, config satellite.Config, versionInfo version.Info) (*satellite.Admin, error) {
|
2020-02-07 15:56:59 +00:00
|
|
|
prefix := "satellite-admin" + strconv.Itoa(count)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
2020-07-06 22:33:27 +01:00
|
|
|
return satellite.NewAdmin(log, identity, db, versionInfo, &config, nil)
|
2020-02-07 15:56:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (planet *Planet) newRepairer(count int, identity *identity.FullIdentity, db satellite.DB, pointerDB metainfo.PointerDB, config satellite.Config, versionInfo version.Info) (*satellite.Repairer, error) {
|
2019-10-29 14:55:57 +00:00
|
|
|
prefix := "satellite-repairer" + strconv.Itoa(count)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
|
|
|
revocationDB, err := revocation.NewDBFromCfg(config.Server.Config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
2020-01-23 22:17:23 +00:00
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
2019-10-29 14:55:57 +00:00
|
|
|
|
2020-01-17 22:55:53 +00:00
|
|
|
rollupsWriteCache := orders.NewRollupsWriteCache(log.Named("orders-write-cache"), db.Orders(), config.Orders.FlushBatchSize)
|
|
|
|
planet.databases = append(planet.databases, rollupsWriteCacheCloser{rollupsWriteCache})
|
|
|
|
|
2020-05-12 20:10:32 +01:00
|
|
|
return satellite.NewRepairer(log, identity, pointerDB, revocationDB, db.RepairQueue(), db.Buckets(), db.OverlayCache(), rollupsWriteCache, db.Irreparable(), versionInfo, &config, nil)
|
2020-01-17 22:55:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type rollupsWriteCacheCloser struct {
|
|
|
|
*orders.RollupsWriteCache
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cache rollupsWriteCacheCloser) Close() error {
|
|
|
|
return cache.RollupsWriteCache.CloseAndFlush(context.TODO())
|
2019-10-29 14:55:57 +00:00
|
|
|
}
|
2020-03-12 15:40:22 +00:00
|
|
|
|
|
|
|
func (planet *Planet) newGarbageCollection(count int, identity *identity.FullIdentity, db satellite.DB, pointerDB metainfo.PointerDB, config satellite.Config, versionInfo version.Info) (*satellite.GarbageCollection, error) {
|
|
|
|
prefix := "satellite-gc" + strconv.Itoa(count)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
|
|
|
revocationDB, err := revocation.NewDBFromCfg(config.Server.Config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
2020-05-12 20:10:32 +01:00
|
|
|
return satellite.NewGarbageCollection(log, identity, db, pointerDB, revocationDB, versionInfo, &config, nil)
|
2020-03-12 15:40:22 +00:00
|
|
|
}
|
2020-05-26 09:05:43 +01:00
|
|
|
|
|
|
|
// atLeastOne returns 1 if value < 1, or value otherwise.
|
|
|
|
func atLeastOne(value int) int {
|
|
|
|
if value < 1 {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|