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"
|
2019-12-04 03:36:21 +00:00
|
|
|
"fmt"
|
2019-10-14 21:01:53 +01:00
|
|
|
"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"
|
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-12-04 03:36:21 +00:00
|
|
|
"storj.io/storj/private/dbutil"
|
2019-11-22 19:59:46 +00:00
|
|
|
"storj.io/storj/private/dbutil/pgutil/pgtest"
|
2019-12-04 03:36:21 +00:00
|
|
|
"storj.io/storj/private/dbutil/tempdb"
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/version"
|
|
|
|
versionchecker "storj.io/storj/private/version/checker"
|
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"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/accounting/rollup"
|
|
|
|
"storj.io/storj/satellite/accounting/tally"
|
|
|
|
"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-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"
|
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"
|
|
|
|
"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"
|
2019-10-18 20:03:10 +01:00
|
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/vouchers"
|
2019-06-21 14:39:43 +01:00
|
|
|
)
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
// SatelliteSystem contains all the processes needed to run a full Satellite setup
|
|
|
|
type SatelliteSystem struct {
|
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
|
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 {
|
|
|
|
Endpoint *orders.Endpoint
|
|
|
|
Service *orders.Service
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
DBCleanup struct {
|
|
|
|
Chore *dbcleanup.Chore
|
|
|
|
}
|
|
|
|
|
|
|
|
Accounting struct {
|
|
|
|
Tally *tally.Service
|
|
|
|
Rollup *rollup.Service
|
2019-11-15 14:27:44 +00:00
|
|
|
ProjectUsage *accounting.Service
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
Vouchers struct {
|
|
|
|
Endpoint *vouchers.Endpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
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-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns the ID of the Satellite system.
|
|
|
|
func (system *SatelliteSystem) ID() storj.NodeID { return system.API.Identity.ID }
|
|
|
|
|
|
|
|
// Local returns the peer local node info from the Satellite system API.
|
|
|
|
func (system *SatelliteSystem) Local() overlay.NodeDossier { return system.API.Contact.Service.Local() }
|
|
|
|
|
|
|
|
// Addr returns the public address from the Satellite system API.
|
|
|
|
func (system *SatelliteSystem) Addr() string { return system.API.Server.Addr().String() }
|
|
|
|
|
|
|
|
// URL returns the storj.NodeURL from the Satellite system API.
|
|
|
|
func (system *SatelliteSystem) URL() storj.NodeURL {
|
|
|
|
return storj.NodeURL{ID: system.API.ID(), Address: system.API.Addr()}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close closes all the subsystems in the Satellite system
|
|
|
|
func (system *SatelliteSystem) Close() error {
|
2019-11-04 19:01:02 +00:00
|
|
|
return errs.Combine(system.API.Close(), system.Core.Close(), system.Repairer.Close())
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run runs all the subsystems in the Satellite system
|
|
|
|
func (system *SatelliteSystem) Run(ctx context.Context) (err error) {
|
|
|
|
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))
|
|
|
|
})
|
2019-10-14 21:01:53 +01:00
|
|
|
return group.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrivateAddr returns the private address from the Satellite system API.
|
|
|
|
func (system *SatelliteSystem) PrivateAddr() string { return system.API.Server.PrivateAddr().String() }
|
|
|
|
|
2019-06-21 14:39:43 +01:00
|
|
|
// newSatellites initializes satellites
|
2019-09-17 21:14:49 +01:00
|
|
|
func (planet *Planet) newSatellites(count int) ([]*SatelliteSystem, error) {
|
|
|
|
var xs []*SatelliteSystem
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
var db satellite.DB
|
|
|
|
if planet.config.Reconfigure.NewSatelliteDB != nil {
|
|
|
|
db, err = planet.config.Reconfigure.NewSatelliteDB(log.Named("db"), i)
|
|
|
|
} else {
|
2019-12-04 03:36:21 +00:00
|
|
|
// TODO: This is analogous to the way we worked prior to the advent of OpenUnique,
|
|
|
|
// but it seems wrong. Tests that use planet.Start() instead of testplanet.Run()
|
|
|
|
// will not get run against both types of DB.
|
|
|
|
connStr := *pgtest.ConnStr
|
2019-11-22 19:59:46 +00:00
|
|
|
if *pgtest.CrdbConnStr != "" {
|
2019-12-04 03:36:21 +00:00
|
|
|
connStr = *pgtest.CrdbConnStr
|
2019-11-22 19:59:46 +00:00
|
|
|
}
|
2019-12-04 03:36:21 +00:00
|
|
|
var tempDB *dbutil.TempDatabase
|
|
|
|
tempDB, err = tempdb.OpenUnique(connStr, fmt.Sprintf("%s.%d", planet.id, i))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
db, err = satellitedbtest.CreateMasterDBOnTopOf(log.Named("db"), tempDB)
|
2019-06-21 14:39:43 +01:00
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-10-10 19:06:26 +01:00
|
|
|
var pointerDB metainfo.PointerDB
|
|
|
|
if planet.config.Reconfigure.NewSatellitePointerDB != nil {
|
|
|
|
pointerDB, err = planet.config.Reconfigure.NewSatellitePointerDB(log.Named("pointerdb"), i)
|
|
|
|
} else {
|
|
|
|
pointerDB, err = metainfo.NewStore(log.Named("pointerdb"), "bolt://"+filepath.Join(storageDir, "pointers.db"))
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Overlay: overlay.Config{
|
|
|
|
Node: overlay.NodeSelectionConfig{
|
|
|
|
UptimeCount: 0,
|
|
|
|
AuditCount: 0,
|
|
|
|
NewNodePercentage: 0,
|
2019-11-15 22:43:06 +00:00
|
|
|
OnlineWindow: time.Minute,
|
2019-06-21 14:39:43 +01:00
|
|
|
DistinctIP: false,
|
|
|
|
|
|
|
|
AuditReputationRepairWeight: 1,
|
|
|
|
AuditReputationUplinkWeight: 1,
|
|
|
|
AuditReputationAlpha0: 1,
|
|
|
|
AuditReputationBeta0: 0,
|
2019-06-21 17:27:19 +01:00
|
|
|
AuditReputationLambda: 0.95,
|
2019-06-21 14:39:43 +01:00
|
|
|
AuditReputationWeight: 1,
|
2019-06-21 17:27:19 +01:00
|
|
|
AuditReputationDQ: 0.6,
|
2019-06-21 14:39:43 +01:00
|
|
|
UptimeReputationRepairWeight: 1,
|
|
|
|
UptimeReputationUplinkWeight: 1,
|
2019-06-21 17:27:19 +01:00
|
|
|
UptimeReputationAlpha0: 2,
|
2019-06-21 14:39:43 +01:00
|
|
|
UptimeReputationBeta0: 0,
|
2019-06-21 17:27:19 +01:00
|
|
|
UptimeReputationLambda: 0.99,
|
2019-06-21 14:39:43 +01:00
|
|
|
UptimeReputationWeight: 1,
|
2019-06-21 17:27:19 +01:00
|
|
|
UptimeReputationDQ: 0.6,
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
2019-07-31 18:21:06 +01:00
|
|
|
UpdateStatsBatchSize: 100,
|
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
|
2019-06-21 14:39:43 +01:00
|
|
|
MaxInlineSegmentSize: 8000,
|
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{
|
2019-10-31 19:04:33 +00:00
|
|
|
MaxSegmentSize: 64 * memory.MiB,
|
|
|
|
MaxBufferMem: memory.Size(256),
|
|
|
|
ErasureShareSize: memory.Size(256),
|
|
|
|
MinThreshold: (planet.config.StorageNodeCount * 1 / 5),
|
|
|
|
RepairThreshold: (planet.config.StorageNodeCount * 2 / 5),
|
|
|
|
SuccessThreshold: (planet.config.StorageNodeCount * 3 / 5),
|
|
|
|
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,
|
2019-07-22 14:34:12 +01:00
|
|
|
},
|
2019-06-21 14:39:43 +01:00
|
|
|
},
|
|
|
|
Orders: orders.Config{
|
2019-07-10 22:17:00 +01:00
|
|
|
Expiration: 7 * 24 * time.Hour,
|
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
|
|
|
},
|
|
|
|
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,
|
2019-07-11 23:44:47 +01:00
|
|
|
MaxBufferMem: 4 * memory.MiB,
|
|
|
|
MaxExcessRateOptimalThreshold: 0.05,
|
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,
|
|
|
|
WorkerConcurrency: 1,
|
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,
|
|
|
|
},
|
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{
|
2019-09-25 16:41:24 +01:00
|
|
|
Interval: defaultInterval,
|
2019-06-21 14:39:43 +01:00
|
|
|
MaxAlphaUsage: 25 * memory.GB,
|
|
|
|
DeleteTallies: false,
|
|
|
|
},
|
|
|
|
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"),
|
|
|
|
PasswordCost: console.TestPasswordCost,
|
|
|
|
AuthTokenSecret: "my-suppa-secret-key",
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
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-10-16 17:50:29 +01:00
|
|
|
liveAccountingCache, err := live.NewCache(log.Named("live-accounting"), config.LiveAccounting)
|
|
|
|
if err != nil {
|
|
|
|
return xs, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
planet.databases = append(planet.databases, liveAccountingCache)
|
|
|
|
|
|
|
|
peer, err := satellite.New(log, identity, db, pointerDB, revocationDB, liveAccountingCache, versionInfo, &config)
|
2019-06-21 14:39:43 +01:00
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
|
|
|
|
2019-08-20 16:04:17 +01:00
|
|
|
err = db.CreateTables()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, db)
|
2019-10-10 19:06:26 +01:00
|
|
|
planet.databases = append(planet.databases, pointerDB)
|
2019-08-20 16:04:17 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
repairerPeer, err := planet.newRepairer(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
|
|
|
|
2019-10-29 14:55:57 +00:00
|
|
|
system := createNewSystem(log, peer, api, repairerPeer)
|
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.
|
2019-11-04 19:01:02 +00:00
|
|
|
func createNewSystem(log *zap.Logger, peer *satellite.Core, api *satellite.API, repairerPeer *satellite.Repairer) *SatelliteSystem {
|
2019-10-14 21:01:53 +01:00
|
|
|
system := &SatelliteSystem{
|
2019-11-04 19:01:02 +00:00
|
|
|
Core: peer,
|
2019-10-29 14:55:57 +00:00
|
|
|
API: api,
|
|
|
|
Repairer: repairerPeer,
|
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
|
|
|
|
|
|
|
|
system.Orders.Endpoint = api.Orders.Endpoint
|
|
|
|
system.Orders.Service = peer.Orders.Service
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
system.GarbageCollection.Service = peer.GarbageCollection.Service
|
|
|
|
|
|
|
|
system.DBCleanup.Chore = peer.DBCleanup.Chore
|
|
|
|
|
|
|
|
system.Accounting.Tally = peer.Accounting.Tally
|
|
|
|
system.Accounting.Rollup = peer.Accounting.Rollup
|
|
|
|
system.Accounting.ProjectUsage = peer.Accounting.ProjectUsage
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
return satellite.NewAPI(log, identity, db, pointerDB, revocationDB, liveAccounting, &config, versionInfo)
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
2019-10-29 14:55:57 +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) {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
return satellite.NewRepairer(log, identity, pointerDB, revocationDB, db.RepairQueue(), db.Buckets(), db.OverlayCache(), db.Orders(), versionInfo, &config)
|
|
|
|
}
|