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"
|
2020-10-29 11:58:36 +00:00
|
|
|
"runtime/pprof"
|
2019-06-21 14:39:43 +01:00
|
|
|
"strconv"
|
|
|
|
|
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
|
|
|
"github.com/spf13/pflag"
|
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/rpc"
|
|
|
|
"storj.io/common/storj"
|
2020-05-19 11:21:56 +01:00
|
|
|
"storj.io/common/uuid"
|
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
|
|
|
"storj.io/private/cfgstruct"
|
2020-03-23 19:30:31 +00:00
|
|
|
"storj.io/private/version"
|
2021-04-23 14:13:51 +01:00
|
|
|
"storj.io/storj/private/revocation"
|
|
|
|
"storj.io/storj/private/server"
|
2021-03-09 17:42:10 +00:00
|
|
|
"storj.io/storj/private/testredis"
|
2019-11-14 19:46:15 +00:00
|
|
|
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"
|
2020-07-07 15:48:09 +01:00
|
|
|
"storj.io/storj/satellite/accounting/projectbwcleanup"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/accounting/rollup"
|
2020-11-30 19:34:42 +00:00
|
|
|
"storj.io/storj/satellite/accounting/rolluparchive"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/accounting/tally"
|
|
|
|
"storj.io/storj/satellite/audit"
|
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
|
|
|
"storj.io/storj/satellite/compensation"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/satellite/console"
|
|
|
|
"storj.io/storj/satellite/console/consoleweb"
|
2022-12-12 11:33:58 +00:00
|
|
|
"storj.io/storj/satellite/console/userinfo"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/contact"
|
2022-08-29 10:44:54 +01:00
|
|
|
"storj.io/storj/satellite/gc/sender"
|
2019-10-07 21:38:05 +01:00
|
|
|
"storj.io/storj/satellite/gracefulexit"
|
2019-06-21 14:39:43 +01:00
|
|
|
"storj.io/storj/satellite/mailservice"
|
2021-05-13 09:14:18 +01:00
|
|
|
"storj.io/storj/satellite/metabase"
|
2021-05-06 12:54:10 +01:00
|
|
|
"storj.io/storj/satellite/metabase/zombiedeletion"
|
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"
|
2022-11-07 19:08:53 +00:00
|
|
|
"storj.io/storj/satellite/nodeevents"
|
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"
|
2022-10-07 21:28:51 +01:00
|
|
|
"storj.io/storj/satellite/overlay/offlinenodes"
|
2020-12-31 18:43:13 +00:00
|
|
|
"storj.io/storj/satellite/overlay/straynodes"
|
2023-04-06 12:41:14 +01:00
|
|
|
"storj.io/storj/satellite/payments/stripe"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/satellite/repair/repairer"
|
2021-06-23 00:09:39 +01:00
|
|
|
"storj.io/storj/satellite/reputation"
|
2020-03-27 16:18:19 +00:00
|
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
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 {
|
2020-10-29 11:58:36 +00:00
|
|
|
Name string
|
2020-03-27 14:46:40 +00:00
|
|
|
Config satellite.Config
|
|
|
|
|
2022-12-14 12:36:48 +00:00
|
|
|
Core *satellite.Core
|
|
|
|
API *satellite.API
|
|
|
|
Repairer *satellite.Repairer
|
2022-10-12 21:33:31 +01:00
|
|
|
Auditor *satellite.Auditor
|
2022-12-14 12:36:48 +00:00
|
|
|
Admin *satellite.Admin
|
|
|
|
GC *satellite.GarbageCollection
|
|
|
|
GCBF *satellite.GarbageCollectionBF
|
|
|
|
RangedLoop *satellite.RangedLoop
|
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 {
|
2022-10-07 21:28:51 +01:00
|
|
|
DB overlay.DB
|
|
|
|
Service *overlay.Service
|
|
|
|
OfflineNodeEmails *offlinenodes.Chore
|
|
|
|
DQStrayNodes *straynodes.Chore
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
2022-11-07 19:08:53 +00:00
|
|
|
NodeEvents struct {
|
|
|
|
DB nodeevents.DB
|
|
|
|
Notifier nodeevents.Notifier
|
|
|
|
Chore *nodeevents.Chore
|
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
Metainfo struct {
|
2021-09-07 09:15:47 +01:00
|
|
|
// TODO remove when uplink will be adjusted to use Metabase.DB
|
|
|
|
Metabase *metabase.DB
|
|
|
|
Endpoint *metainfo.Endpoint
|
|
|
|
}
|
|
|
|
|
2022-12-12 11:33:58 +00:00
|
|
|
Userinfo struct {
|
|
|
|
Endpoint *userinfo.Endpoint
|
|
|
|
}
|
|
|
|
|
2021-09-07 09:15:47 +01:00
|
|
|
Metabase struct {
|
2023-05-10 09:36:52 +01:00
|
|
|
DB *metabase.DB
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2021-06-15 22:45:31 +01:00
|
|
|
Repairer *repairer.Service
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
2020-12-31 18:43:13 +00:00
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
Audit struct {
|
2023-01-26 01:21:47 +00:00
|
|
|
VerifyQueue audit.VerifyQueue
|
|
|
|
ReverifyQueue audit.ReverifyQueue
|
|
|
|
Worker *audit.Worker
|
|
|
|
ReverifyWorker *audit.ReverifyWorker
|
|
|
|
Verifier *audit.Verifier
|
|
|
|
Reverifier *audit.Reverifier
|
|
|
|
Reporter audit.Reporter
|
|
|
|
ContainmentSyncChore *audit.ContainmentSyncChore
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
2021-06-23 00:09:39 +01:00
|
|
|
Reputation struct {
|
|
|
|
Service *reputation.Service
|
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
GarbageCollection struct {
|
2023-05-09 11:09:20 +01:00
|
|
|
Sender *sender.Service
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
2020-04-15 20:20:16 +01:00
|
|
|
ExpiredDeletion struct {
|
|
|
|
Chore *expireddeletion.Chore
|
|
|
|
}
|
|
|
|
|
2021-05-06 12:54:10 +01:00
|
|
|
ZombieDeletion struct {
|
|
|
|
Chore *zombiedeletion.Chore
|
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
Accounting struct {
|
2020-07-07 15:48:09 +01:00
|
|
|
Tally *tally.Service
|
|
|
|
Rollup *rollup.Service
|
|
|
|
ProjectUsage *accounting.Service
|
|
|
|
ProjectBWCleanup *projectbwcleanup.Chore
|
2020-11-30 19:34:42 +00:00
|
|
|
RollupArchive *rolluparchive.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
|
|
|
}
|
|
|
|
|
2020-09-09 20:20:44 +01:00
|
|
|
ProjectLimits struct {
|
|
|
|
Cache *accounting.ProjectLimitCache
|
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
Mail struct {
|
|
|
|
Service *mailservice.Service
|
|
|
|
}
|
|
|
|
|
|
|
|
Console struct {
|
|
|
|
Listener net.Listener
|
|
|
|
Service *console.Service
|
|
|
|
Endpoint *consoleweb.Server
|
|
|
|
}
|
|
|
|
|
|
|
|
NodeStats struct {
|
|
|
|
Endpoint *nodestats.Endpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
GracefulExit struct {
|
|
|
|
Endpoint *gracefulexit.Endpoint
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
// Label returns name for debugger.
|
|
|
|
func (system *Satellite) Label() string { return system.Name }
|
|
|
|
|
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() }
|
|
|
|
|
2021-06-09 12:39:38 +01:00
|
|
|
// ConsoleURL returns the console URL.
|
|
|
|
func (system *Satellite) ConsoleURL() string {
|
|
|
|
return "http://" + system.API.Console.Listener.Addr().String()
|
|
|
|
}
|
|
|
|
|
2020-04-16 13:12:46 +01:00
|
|
|
// 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.
|
2021-09-29 08:06:51 +01:00
|
|
|
func (system *Satellite) AddUser(ctx context.Context, newUser console.CreateUser, maxNumberOfProjects int) (_ *console.User, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-05-19 11:21:56 +01:00
|
|
|
regToken, err := system.API.Console.Service.CreateRegToken(ctx, maxNumberOfProjects)
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
|
2020-07-24 10:40:17 +01:00
|
|
|
newUser.Password = newUser.FullName
|
2021-02-04 18:16:49 +00:00
|
|
|
user, err := system.API.Console.Service.CreateUser(ctx, newUser, regToken.Secret)
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
activationToken, err := system.API.Console.Service.GenerateActivationToken(ctx, user.ID, user.Email)
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
|
2021-10-06 14:33:54 +01:00
|
|
|
_, err = system.API.Console.Service.ActivateAccount(ctx, activationToken)
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
|
2022-06-05 23:41:38 +01:00
|
|
|
userCtx, err := system.UserContext(ctx, user.ID)
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
2022-06-05 23:41:38 +01:00
|
|
|
_, err = system.API.Console.Service.Payments().SetupAccount(userCtx)
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return user, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddProject adds project to a satellite and makes specified user an owner.
|
2021-09-29 08:06:51 +01:00
|
|
|
func (system *Satellite) AddProject(ctx context.Context, ownerID uuid.UUID, name string) (_ *console.Project, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2022-06-05 23:41:38 +01:00
|
|
|
ctx, err = system.UserContext(ctx, ownerID)
|
2020-05-19 11:21:56 +01:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
2022-06-05 23:41:38 +01:00
|
|
|
project, err := system.API.Console.Service.CreateProject(ctx, console.ProjectInfo{
|
2020-05-19 11:21:56 +01:00
|
|
|
Name: name,
|
|
|
|
})
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
return project, nil
|
|
|
|
}
|
|
|
|
|
2022-06-05 23:41:38 +01:00
|
|
|
// UserContext creates context with user.
|
|
|
|
func (system *Satellite) UserContext(ctx context.Context, userID uuid.UUID) (_ context.Context, err error) {
|
2021-09-29 08:06:51 +01:00
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-05-19 11:21:56 +01:00
|
|
|
user, err := system.API.Console.Service.GetUser(ctx, userID)
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
|
2022-06-05 23:41:38 +01:00
|
|
|
return console.WithUser(ctx, user), nil
|
2020-05-19 11:21:56 +01:00
|
|
|
}
|
|
|
|
|
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(),
|
2022-10-12 21:33:31 +01:00
|
|
|
system.Auditor.Close(),
|
2020-02-07 16:36:28 +00:00
|
|
|
system.Admin.Close(),
|
2020-03-12 15:40:22 +00:00
|
|
|
system.GC.Close(),
|
2022-08-30 12:02:13 +01:00
|
|
|
system.GCBF.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))
|
|
|
|
})
|
2022-10-12 21:33:31 +01:00
|
|
|
group.Go(func() error {
|
|
|
|
return errs2.IgnoreCanceled(system.Auditor.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))
|
|
|
|
})
|
2022-08-30 12:02:13 +01:00
|
|
|
group.Go(func() error {
|
|
|
|
return errs2.IgnoreCanceled(system.GCBF.Run(ctx))
|
|
|
|
})
|
2023-05-16 15:08:52 +01:00
|
|
|
group.Go(func() error {
|
|
|
|
return errs2.IgnoreCanceled(system.RangedLoop.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.
|
2021-09-29 08:06:51 +01:00
|
|
|
func (planet *Planet) newSatellites(ctx context.Context, count int, databases satellitedbtest.SatelliteDatabases) (_ []*Satellite, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
var satellites []*Satellite
|
2019-06-21 14:39:43 +01:00
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
2020-10-29 11:58:36 +00:00
|
|
|
index := i
|
|
|
|
prefix := "satellite" + strconv.Itoa(index)
|
2019-06-21 14:39:43 +01:00
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
var system *Satellite
|
|
|
|
var err error
|
2019-06-21 14:39:43 +01:00
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
pprof.Do(ctx, pprof.Labels("peer", prefix), func(ctx context.Context) {
|
2023-02-02 11:34:28 +00:00
|
|
|
system, err = planet.newSatellite(ctx, prefix, index, log, databases, planet.config.applicationName)
|
2020-10-29 11:58:36 +00:00
|
|
|
})
|
2019-06-21 14:39:43 +01:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2019-06-21 14:39:43 +01:00
|
|
|
}
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
log.Debug("id=" + system.ID().String() + " addr=" + system.Addr())
|
|
|
|
satellites = append(satellites, system)
|
|
|
|
planet.peers = append(planet.peers, newClosablePeer(system))
|
|
|
|
}
|
2019-06-21 14:39:43 +01:00
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
return satellites, nil
|
|
|
|
}
|
2020-03-27 16:18:19 +00:00
|
|
|
|
2023-02-02 11:34:28 +00:00
|
|
|
func (planet *Planet) newSatellite(ctx context.Context, prefix string, index int, log *zap.Logger, databases satellitedbtest.SatelliteDatabases, applicationName string) (_ *Satellite, err error) {
|
2021-09-29 08:06:51 +01:00
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
storageDir := filepath.Join(planet.directory, prefix)
|
|
|
|
if err := os.MkdirAll(storageDir, 0700); err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
identity, err := planet.NewIdentity()
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
|
|
|
|
2023-02-02 11:34:28 +00:00
|
|
|
db, err := satellitedbtest.CreateMasterDB(ctx, log.Named("db"), planet.config.Name, "S", index, databases.MasterDB, applicationName)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if planet.config.Reconfigure.SatelliteDB != nil {
|
|
|
|
var newdb satellite.DB
|
|
|
|
newdb, err = planet.config.Reconfigure.SatelliteDB(log.Named("db"), index, db)
|
2019-10-10 19:06:26 +01:00
|
|
|
if err != nil {
|
2020-10-29 11:58:36 +00:00
|
|
|
return nil, errs.Combine(err, db.Close())
|
2019-10-10 19:06:26 +01:00
|
|
|
}
|
2020-10-29 11:58:36 +00:00
|
|
|
db = newdb
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, db)
|
2020-03-27 16:18:19 +00:00
|
|
|
|
2021-03-09 17:42:10 +00:00
|
|
|
redis, err := testredis.Mini(ctx)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
2020-11-18 21:39:13 +00:00
|
|
|
encryptionKeys, err := orders.NewEncryptionKeys(orders.EncryptionKey{
|
|
|
|
ID: orders.EncryptionKeyID{1},
|
|
|
|
Key: storj.Key{1},
|
|
|
|
})
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-11-18 21:39:13 +00:00
|
|
|
}
|
2020-10-29 11:58:36 +00:00
|
|
|
|
2021-10-25 16:29:15 +01:00
|
|
|
var config satellite.Config
|
|
|
|
cfgstruct.Bind(pflag.NewFlagSet("", pflag.PanicOnError), &config,
|
|
|
|
cfgstruct.UseTestDefaults(),
|
|
|
|
cfgstruct.ConfDir(storageDir),
|
|
|
|
cfgstruct.IdentityDir(storageDir),
|
|
|
|
cfgstruct.ConfigVar("TESTINTERVAL", defaultInterval.String()))
|
|
|
|
|
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
|
|
|
// TODO: these are almost certainly mistakenly set to the zero value
|
|
|
|
// in tests due to a prior mismatch between testplanet config and
|
|
|
|
// cfgstruct devDefaults. we need to make sure it's safe to remove
|
|
|
|
// these lines and then remove them.
|
|
|
|
config.Debug.Control = false
|
2021-07-14 00:30:06 +01:00
|
|
|
config.Reputation.AuditHistory.OfflineDQEnabled = false
|
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
|
|
|
config.Server.Config.Extensions.Revocation = false
|
|
|
|
config.Orders.OrdersSemaphoreSize = 0
|
|
|
|
config.Checker.NodeFailureRate = 0
|
|
|
|
config.Audit.MaxRetriesStatDB = 0
|
|
|
|
config.GarbageCollection.RetainSendTimeout = 0
|
|
|
|
config.ExpiredDeletion.ListLimit = 0
|
|
|
|
config.Tally.SaveRollupBatchSize = 0
|
|
|
|
config.Tally.ReadRollupBatchSize = 0
|
|
|
|
config.Rollup.DeleteTallies = false
|
|
|
|
config.Payments.BonusRate = 0
|
|
|
|
config.Identity.CertPath = ""
|
|
|
|
config.Identity.KeyPath = ""
|
|
|
|
config.Metainfo.DatabaseURL = ""
|
|
|
|
config.Console.ContactInfoURL = ""
|
|
|
|
config.Console.FrameAncestors = ""
|
|
|
|
config.Console.LetUsKnowURL = ""
|
|
|
|
config.Console.SEO = ""
|
|
|
|
config.Console.SatelliteOperator = ""
|
|
|
|
config.Console.TermsAndConditionsURL = ""
|
|
|
|
config.Console.GeneralRequestURL = ""
|
|
|
|
config.Console.ProjectLimitsIncreaseRequestURL = ""
|
|
|
|
config.Console.GatewayCredentialsRequestURL = ""
|
|
|
|
config.Console.DocumentationURL = ""
|
|
|
|
config.Console.LinksharingURL = ""
|
|
|
|
config.Console.PathwayOverviewEnabled = false
|
|
|
|
config.Compensation.Rates.AtRestGBHours = compensation.Rate{}
|
|
|
|
config.Compensation.Rates.GetTB = compensation.Rate{}
|
|
|
|
config.Compensation.Rates.GetRepairTB = compensation.Rate{}
|
|
|
|
config.Compensation.Rates.GetAuditTB = compensation.Rate{}
|
|
|
|
config.Compensation.WithheldPercents = nil
|
|
|
|
config.Compensation.DisposePercent = 0
|
|
|
|
config.ProjectLimit.CacheCapacity = 0
|
|
|
|
config.ProjectLimit.CacheExpiration = 0
|
|
|
|
|
|
|
|
// Actual testplanet-specific configuration
|
2022-03-28 19:05:53 +01:00
|
|
|
config.Server.Address = planet.NewListenAddress()
|
|
|
|
config.Server.PrivateAddress = planet.NewListenAddress()
|
|
|
|
config.Admin.Address = planet.NewListenAddress()
|
|
|
|
config.Console.Address = planet.NewListenAddress()
|
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
|
|
|
config.Server.Config.PeerCAWhitelistPath = planet.whitelistPath
|
|
|
|
config.Server.Config.UsePeerCAWhitelist = true
|
|
|
|
config.Version = planet.NewVersionConfig()
|
|
|
|
config.Metainfo.RS.Min = atLeastOne(planet.config.StorageNodeCount * 1 / 5)
|
|
|
|
config.Metainfo.RS.Repair = atLeastOne(planet.config.StorageNodeCount * 2 / 5)
|
|
|
|
config.Metainfo.RS.Success = atLeastOne(planet.config.StorageNodeCount * 3 / 5)
|
|
|
|
config.Metainfo.RS.Total = atLeastOne(planet.config.StorageNodeCount * 4 / 5)
|
|
|
|
config.Orders.EncryptionKeys = *encryptionKeys
|
|
|
|
config.LiveAccounting.StorageBackend = "redis://" + redis.Addr() + "?db=0"
|
|
|
|
config.Mail.TemplatePath = filepath.Join(developmentRoot, "web/satellite/static/emails")
|
|
|
|
config.Console.StaticDir = filepath.Join(developmentRoot, "web/satellite")
|
2022-07-08 16:23:56 +01:00
|
|
|
config.Payments.Storjscan.DisableLoop = true
|
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
if planet.config.Reconfigure.Satellite != nil {
|
|
|
|
planet.config.Reconfigure.Satellite(log, index, &config)
|
|
|
|
}
|
2019-11-21 22:34:49 +00:00
|
|
|
|
2021-10-25 16:29:15 +01:00
|
|
|
metabaseDB, err := satellitedbtest.CreateMetabaseDB(context.TODO(), log.Named("metabase"), planet.config.Name, "M", index, databases.MetabaseDB, metabase.Config{
|
2022-02-20 21:29:41 +00:00
|
|
|
ApplicationName: "satellite-testplanet",
|
2021-10-25 16:29:15 +01:00
|
|
|
MinPartSize: config.Metainfo.MinPartSize,
|
|
|
|
MaxNumberOfParts: config.Metainfo.MaxNumberOfParts,
|
2022-02-11 10:59:00 +00:00
|
|
|
ServerSideCopy: config.Metainfo.ServerSideCopy,
|
2021-10-25 16:29:15 +01:00
|
|
|
})
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2021-10-25 16:29:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if planet.config.Reconfigure.SatelliteMetabaseDB != nil {
|
|
|
|
var newMetabaseDB *metabase.DB
|
|
|
|
newMetabaseDB, err = planet.config.Reconfigure.SatelliteMetabaseDB(log.Named("metabase"), index, metabaseDB)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, metabaseDB.Close())
|
|
|
|
}
|
|
|
|
metabaseDB = newMetabaseDB
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, metabaseDB)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
versionInfo := planet.NewVersionInfo()
|
2019-08-19 23:10:38 +01:00
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
revocationDB, err := revocation.OpenDBFromCfg(ctx, config.Server.Config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
2019-10-16 17:50:29 +01:00
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
2020-01-17 22:55:53 +00:00
|
|
|
|
2021-03-24 19:22:50 +00:00
|
|
|
liveAccounting, err := live.OpenCache(ctx, log.Named("live-accounting"), config.LiveAccounting)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, liveAccounting)
|
2019-06-21 14:39:43 +01:00
|
|
|
|
2023-03-03 18:10:01 +00:00
|
|
|
config.Payments.Provider = "mock"
|
2023-04-06 12:41:14 +01:00
|
|
|
config.Payments.MockProvider = stripe.NewStripeMock(db.StripeCoinPayments().Customers(), db.Console().Users())
|
2023-03-03 18:10:01 +00:00
|
|
|
|
2023-03-07 09:29:25 +00:00
|
|
|
peer, err := satellite.New(log, identity, db, metabaseDB, revocationDB, liveAccounting, versionInfo, &config, nil)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
2019-10-29 14:55:57 +00:00
|
|
|
|
satellite/overlay: configurable meaning of last_net
Up to now, we have been implementing the DistinctIP preference with code
in two places:
1. On check-in, the last_net is determined by taking the /24 or /64
(in ResolveIPAndNetwork()) and we store it with the node record.
2. On node selection, a preference parameter defines whether to return
results that are distinct on last_net.
It can be observed that we have never yet had the need to switch from
DistinctIP to !DistinctIP, or from !DistinctIP to DistinctIP, on the
same satellite, and we will probably never need to do so in an automated
way. It can also be observed that this arrangement makes tests more
complicated, because we often have to arrange for test nodes to have IP
addresses in different /24 networks (a particular pain on macOS).
Those two considerations, plus some pending work on the repair framework
that will make repair take last_net into consideration, motivate this
change.
With this change, in the #2 place, we will _always_ return results that
are distinct on last_net. We implement the DistinctIP preference, then,
by making the #1 place (ResolveIPAndNetwork()) more flexible. When
DistinctIP is enabled, last_net will be calculated as it was before. But
when DistinctIP is _off_, last_net can be the same as address (IP and
port). That will effectively implement !DistinctIP because every
record will have a distinct last_net already.
As a side effect, this flexibility will allow us to change the rules
about last_net construction arbitrarily. We can do tests where last_net
is set to the source IP, or to a /30 prefix, or a /16 prefix, etc., and
be able to exercise the production logic without requiring a virtual
network bridge.
This change should be safe to make without any migration code, because
all known production satellite deployments use DistinctIP, and the
associated last_net values will not change for them. They will only
change for satellites with !DistinctIP, which are mostly test
deployments that can be recreated trivially. For those satellites which
are both permanent and !DistinctIP, node selection will suddenly start
acting as though DistinctIP is enabled, until the operator runs a single
SQL update "UPDATE nodes SET last_net = last_ip_port". That can be done
either before or after deploying software with this change.
I also assert that this will not hurt performance for production
deployments. It's true that adding the distinct requirement to node
selection makes things a little slower, but the distinct requirement is
already present for all production deployments, and they will see no
change.
Refs: https://github.com/storj/storj/issues/5391
Change-Id: I0e7e92498c3da768df5b4d5fb213dcd2d4862924
2023-02-28 22:57:39 +00:00
|
|
|
if planet.config.LastNetFunc != nil {
|
|
|
|
peer.Overlay.Service.LastNetFunc = planet.config.LastNetFunc
|
|
|
|
}
|
|
|
|
|
2023-02-06 12:15:36 +00:00
|
|
|
err = db.Testing().TestMigrateToLatest(ctx)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
2020-02-07 15:56:59 +00:00
|
|
|
|
2022-06-01 11:18:56 +01:00
|
|
|
err = metabaseDB.TestMigrateToLatest(ctx)
|
2021-02-11 11:58:22 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2021-02-11 11:58:22 +00:00
|
|
|
}
|
|
|
|
|
2020-12-22 10:38:32 +00:00
|
|
|
api, err := planet.newAPI(ctx, index, identity, db, metabaseDB, config, versionInfo)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
2019-10-29 14:55:57 +00:00
|
|
|
|
2021-11-12 20:47:41 +00:00
|
|
|
adminPeer, err := planet.newAdmin(ctx, index, identity, db, metabaseDB, config, versionInfo)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
2020-03-12 15:40:22 +00:00
|
|
|
|
2020-12-22 10:38:32 +00:00
|
|
|
repairerPeer, err := planet.newRepairer(ctx, index, identity, db, metabaseDB, config, versionInfo)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2020-10-29 11:58:36 +00:00
|
|
|
}
|
2019-09-17 21:14:49 +01:00
|
|
|
|
2022-10-12 21:33:31 +01:00
|
|
|
auditorPeer, err := planet.newAuditor(ctx, index, identity, db, metabaseDB, config, versionInfo)
|
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2022-10-12 21:33:31 +01:00
|
|
|
}
|
|
|
|
|
2020-12-22 10:38:32 +00:00
|
|
|
gcPeer, err := planet.newGarbageCollection(ctx, index, identity, db, metabaseDB, config, versionInfo)
|
2020-10-29 11:58:36 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2019-06-21 14:39:43 +01:00
|
|
|
}
|
2020-10-29 11:58:36 +00:00
|
|
|
|
2023-02-13 09:36:04 +00:00
|
|
|
gcBFPeer, err := planet.newGarbageCollectionBF(ctx, index, db, metabaseDB, config, versionInfo)
|
2022-08-30 12:02:13 +01:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2022-08-30 12:02:13 +01:00
|
|
|
}
|
|
|
|
|
2023-01-03 14:36:26 +00:00
|
|
|
rangedLoopPeer, err := planet.newRangedLoop(ctx, index, db, metabaseDB, config)
|
2022-12-14 12:36:48 +00:00
|
|
|
if err != nil {
|
2023-01-31 13:44:59 +00:00
|
|
|
return nil, errs.Wrap(err)
|
2022-12-14 12:36:48 +00:00
|
|
|
}
|
|
|
|
|
2022-05-27 18:16:14 +01:00
|
|
|
if config.EmailReminders.Enable {
|
|
|
|
peer.Mail.EmailReminders.TestSetLinkAddress("http://" + api.Console.Listener.Addr().String() + "/")
|
|
|
|
}
|
2022-01-06 19:46:53 +00:00
|
|
|
|
2022-10-12 21:33:31 +01:00
|
|
|
return createNewSystem(prefix, log, config, peer, api, repairerPeer, auditorPeer, adminPeer, gcPeer, gcBFPeer, rangedLoopPeer), nil
|
2019-06-21 14:39:43 +01:00
|
|
|
}
|
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
|
2022-05-07 20:04:12 +01:00
|
|
|
// so it represents how the satellite will run when it is made up of many processes.
|
2022-10-12 21:33:31 +01:00
|
|
|
func createNewSystem(name string, log *zap.Logger, config satellite.Config, peer *satellite.Core, api *satellite.API, repairerPeer *satellite.Repairer, auditorPeer *satellite.Auditor, adminPeer *satellite.Admin, gcPeer *satellite.GarbageCollection, gcBFPeer *satellite.GarbageCollectionBF, rangedLoopPeer *satellite.RangedLoop) *Satellite {
|
2020-03-27 14:46:40 +00:00
|
|
|
system := &Satellite{
|
2022-12-14 12:36:48 +00:00
|
|
|
Name: name,
|
|
|
|
Config: config,
|
|
|
|
Core: peer,
|
|
|
|
API: api,
|
|
|
|
Repairer: repairerPeer,
|
2022-10-12 21:33:31 +01:00
|
|
|
Auditor: auditorPeer,
|
2022-12-14 12:36:48 +00:00
|
|
|
Admin: adminPeer,
|
|
|
|
GC: gcPeer,
|
|
|
|
GCBF: gcBFPeer,
|
|
|
|
RangedLoop: rangedLoopPeer,
|
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
|
2022-10-07 21:28:51 +01:00
|
|
|
system.Overlay.OfflineNodeEmails = peer.Overlay.OfflineNodeEmails
|
2020-12-31 18:43:13 +00:00
|
|
|
system.Overlay.DQStrayNodes = peer.Overlay.DQStrayNodes
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2022-11-07 19:08:53 +00:00
|
|
|
system.NodeEvents.DB = peer.NodeEvents.DB
|
|
|
|
system.NodeEvents.Notifier = peer.NodeEvents.Notifier
|
|
|
|
system.NodeEvents.Chore = peer.NodeEvents.Chore
|
|
|
|
|
2021-06-23 00:09:39 +01:00
|
|
|
system.Reputation.Service = peer.Reputation.Service
|
|
|
|
|
2021-09-07 09:15:47 +01:00
|
|
|
// system.Metainfo.Metabase = api.Metainfo.Metabase
|
2021-06-16 17:19:14 +01:00
|
|
|
system.Metainfo.Endpoint = api.Metainfo.Endpoint
|
2021-09-07 09:15:47 +01:00
|
|
|
// system.Metainfo.SegmentLoop = peer.Metainfo.SegmentLoop
|
|
|
|
|
2022-12-12 11:33:58 +00:00
|
|
|
system.Userinfo.Endpoint = api.Userinfo.Endpoint
|
|
|
|
|
2021-09-07 09:15:47 +01:00
|
|
|
system.Metabase.DB = api.Metainfo.Metabase
|
2019-10-14 21:01:53 +01:00
|
|
|
|
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
|
2023-03-07 09:29:25 +00:00
|
|
|
system.Orders.Service = api.Orders.Service
|
2020-01-10 18:53:42 +00:00
|
|
|
system.Orders.Chore = api.Orders.Chore
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2019-10-29 14:55:57 +00:00
|
|
|
system.Repair.Repairer = repairerPeer.Repairer
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2022-10-12 21:33:31 +01:00
|
|
|
system.Audit.VerifyQueue = auditorPeer.Audit.VerifyQueue
|
|
|
|
system.Audit.ReverifyQueue = auditorPeer.Audit.ReverifyQueue
|
|
|
|
system.Audit.Worker = auditorPeer.Audit.Worker
|
|
|
|
system.Audit.ReverifyWorker = auditorPeer.Audit.ReverifyWorker
|
|
|
|
system.Audit.Verifier = auditorPeer.Audit.Verifier
|
|
|
|
system.Audit.Reverifier = auditorPeer.Audit.Reverifier
|
|
|
|
system.Audit.Reporter = auditorPeer.Audit.Reporter
|
2023-01-26 01:21:47 +00:00
|
|
|
system.Audit.ContainmentSyncChore = peer.Audit.ContainmentSyncChore
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2022-08-29 10:44:54 +01:00
|
|
|
system.GarbageCollection.Sender = gcPeer.GarbageCollection.Sender
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2020-04-15 20:20:16 +01:00
|
|
|
system.ExpiredDeletion.Chore = peer.ExpiredDeletion.Chore
|
2021-05-06 12:54:10 +01:00
|
|
|
system.ZombieDeletion.Chore = peer.ZombieDeletion.Chore
|
2020-04-15 20:20:16 +01:00
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
system.Accounting.Tally = peer.Accounting.Tally
|
|
|
|
system.Accounting.Rollup = peer.Accounting.Rollup
|
2020-09-09 20:20:44 +01:00
|
|
|
system.Accounting.ProjectUsage = api.Accounting.ProjectUsage
|
2020-07-07 15:48:09 +01:00
|
|
|
system.Accounting.ProjectBWCleanup = peer.Accounting.ProjectBWCleanupChore
|
2020-11-30 19:34:42 +00:00
|
|
|
system.Accounting.RollupArchive = peer.Accounting.RollupArchiveChore
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2020-01-31 18:28:42 +00:00
|
|
|
system.LiveAccounting = peer.LiveAccounting
|
|
|
|
|
2020-09-09 20:20:44 +01:00
|
|
|
system.ProjectLimits.Cache = api.ProjectLimits.Cache
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
system.GracefulExit.Endpoint = api.GracefulExit.Endpoint
|
2019-10-16 19:08:33 +01:00
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
return system
|
|
|
|
}
|
|
|
|
|
2021-09-29 08:06:51 +01:00
|
|
|
func (planet *Planet) newAPI(ctx context.Context, index int, identity *identity.FullIdentity, db satellite.DB, metabaseDB *metabase.DB, config satellite.Config, versionInfo version.Info) (_ *satellite.API, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
prefix := "satellite-api" + strconv.Itoa(index)
|
2019-10-14 21:01:53 +01:00
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
2020-10-28 14:01:41 +00:00
|
|
|
revocationDB, err := revocation.OpenDBFromCfg(ctx, config.Server.Config)
|
2019-10-14 21:01:53 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
|
|
|
|
2021-03-24 19:22:50 +00:00
|
|
|
liveAccounting, err := live.OpenCache(ctx, log.Named("live-accounting"), config.LiveAccounting)
|
2019-10-16 17:50:29 +01:00
|
|
|
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-12-22 10:38:32 +00:00
|
|
|
return satellite.NewAPI(log, identity, db, metabaseDB, revocationDB, liveAccounting, rollupsWriteCache, &config, versionInfo, nil)
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
2019-10-29 14:55:57 +00:00
|
|
|
|
2021-11-12 20:47:41 +00:00
|
|
|
func (planet *Planet) newAdmin(ctx context.Context, index int, identity *identity.FullIdentity, db satellite.DB, metabaseDB *metabase.DB, config satellite.Config, versionInfo version.Info) (_ *satellite.Admin, err error) {
|
2021-09-29 08:06:51 +01:00
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
prefix := "satellite-admin" + strconv.Itoa(index)
|
2020-02-07 15:56:59 +00:00
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
2021-11-12 20:47:41 +00:00
|
|
|
return satellite.NewAdmin(log, identity, db, metabaseDB, versionInfo, &config, nil)
|
2020-02-07 15:56:59 +00:00
|
|
|
}
|
|
|
|
|
2021-09-29 08:06:51 +01:00
|
|
|
func (planet *Planet) newRepairer(ctx context.Context, index int, identity *identity.FullIdentity, db satellite.DB, metabaseDB *metabase.DB, config satellite.Config, versionInfo version.Info) (_ *satellite.Repairer, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
prefix := "satellite-repairer" + strconv.Itoa(index)
|
2019-10-29 14:55:57 +00:00
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
2020-10-28 14:01:41 +00:00
|
|
|
revocationDB, err := revocation.OpenDBFromCfg(ctx, config.Server.Config)
|
2019-10-29 14:55:57 +00:00
|
|
|
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
|
|
|
|
2023-03-07 09:29:25 +00:00
|
|
|
return satellite.NewRepairer(log, identity, metabaseDB, revocationDB, db.RepairQueue(), db.Buckets(), db.OverlayCache(), db.NodeEvents(), db.Reputation(), db.Containment(), versionInfo, &config, nil)
|
2020-01-17 22:55:53 +00:00
|
|
|
}
|
|
|
|
|
2022-10-12 21:33:31 +01:00
|
|
|
func (planet *Planet) newAuditor(ctx context.Context, index int, identity *identity.FullIdentity, db satellite.DB, metabaseDB *metabase.DB, config satellite.Config, versionInfo version.Info) (_ *satellite.Auditor, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
|
|
|
prefix := "satellite-auditor" + strconv.Itoa(index)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
|
|
|
revocationDB, err := revocation.OpenDBFromCfg(ctx, config.Server.Config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
|
|
|
|
2023-03-07 09:29:25 +00:00
|
|
|
return satellite.NewAuditor(log, identity, metabaseDB, revocationDB, db.VerifyQueue(), db.ReverifyQueue(), db.OverlayCache(), db.NodeEvents(), db.Reputation(), db.Containment(), versionInfo, &config, nil)
|
2022-10-12 21:33:31 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-09-29 08:06:51 +01:00
|
|
|
func (planet *Planet) newGarbageCollection(ctx context.Context, index int, identity *identity.FullIdentity, db satellite.DB, metabaseDB *metabase.DB, config satellite.Config, versionInfo version.Info) (_ *satellite.GarbageCollection, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2020-10-29 11:58:36 +00:00
|
|
|
prefix := "satellite-gc" + strconv.Itoa(index)
|
2020-03-12 15:40:22 +00:00
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
2020-10-28 14:01:41 +00:00
|
|
|
revocationDB, err := revocation.OpenDBFromCfg(ctx, config.Server.Config)
|
2020-03-12 15:40:22 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
2020-12-22 10:38:32 +00:00
|
|
|
return satellite.NewGarbageCollection(log, identity, db, metabaseDB, revocationDB, versionInfo, &config, nil)
|
2020-03-12 15:40:22 +00:00
|
|
|
}
|
2020-05-26 09:05:43 +01:00
|
|
|
|
2023-02-13 09:36:04 +00:00
|
|
|
func (planet *Planet) newGarbageCollectionBF(ctx context.Context, index int, db satellite.DB, metabaseDB *metabase.DB, config satellite.Config, versionInfo version.Info) (_ *satellite.GarbageCollectionBF, err error) {
|
2022-08-30 12:02:13 +01:00
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
|
|
|
prefix := "satellite-gc-bf" + strconv.Itoa(index)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
|
|
|
revocationDB, err := revocation.OpenDBFromCfg(ctx, config.Server.Config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Wrap(err)
|
|
|
|
}
|
|
|
|
planet.databases = append(planet.databases, revocationDB)
|
2023-02-13 09:36:04 +00:00
|
|
|
return satellite.NewGarbageCollectionBF(log, db, metabaseDB, revocationDB, versionInfo, &config, nil)
|
2022-08-30 12:02:13 +01:00
|
|
|
}
|
|
|
|
|
2023-01-03 14:36:26 +00:00
|
|
|
func (planet *Planet) newRangedLoop(ctx context.Context, index int, db satellite.DB, metabaseDB *metabase.DB, config satellite.Config) (_ *satellite.RangedLoop, err error) {
|
2022-12-14 12:36:48 +00:00
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
|
|
|
prefix := "satellite-ranged-loop" + strconv.Itoa(index)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
2023-01-03 14:36:26 +00:00
|
|
|
return satellite.NewRangedLoop(log, db, metabaseDB, &config, nil)
|
2022-12-14 12:36:48 +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
|
|
|
|
}
|