cmd: cleanup segment verify/repair tools
* use the same DB application name for satellite and metabase * use noop orders DB implementation to avoid storing allocated bandwidth in DB Change-Id: I20e88c694d38240fe1a20c45719e210cfb76402c
This commit is contained in:
parent
e0f2087245
commit
0185bba90a
@ -21,7 +21,6 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"storj.io/common/context2"
|
||||
"storj.io/common/errs2"
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/peertls/tlsopts"
|
||||
@ -61,7 +60,7 @@ func cmdRepairSegment(cmd *cobra.Command, args []string) (err error) {
|
||||
return errs.New("Failed to load identity: %+v", err)
|
||||
}
|
||||
|
||||
db, err := satellitedb.Open(ctx, log.Named("db"), runCfg.Database, satellitedb.Options{ApplicationName: "satellite-segment-repairer"})
|
||||
db, err := satellitedb.Open(ctx, log.Named("db"), runCfg.Database, satellitedb.Options{ApplicationName: "satellite-repair-segment"})
|
||||
if err != nil {
|
||||
return errs.New("Error starting master database: %+v", err)
|
||||
}
|
||||
@ -86,11 +85,6 @@ func cmdRepairSegment(cmd *cobra.Command, args []string) (err error) {
|
||||
err = errs.Combine(err, revocationDB.Close())
|
||||
}()
|
||||
|
||||
rollupsWriteCache := orders.NewRollupsWriteCache(log.Named("orders-write-cache"), db.Orders(), runCfg.Orders.FlushBatchSize)
|
||||
defer func() {
|
||||
err = errs.Combine(err, rollupsWriteCache.CloseAndFlush(context2.WithoutCancellation(ctx)))
|
||||
}()
|
||||
|
||||
config := runCfg
|
||||
|
||||
tlsOptions, err := tlsopts.NewOptions(identity, config.Server.Config, revocationDB)
|
||||
@ -110,7 +104,7 @@ func cmdRepairSegment(cmd *cobra.Command, args []string) (err error) {
|
||||
log.Named("orders"),
|
||||
signing.SignerFromFullIdentity(identity),
|
||||
overlay,
|
||||
db.Orders(),
|
||||
orders.NewNoopDB(),
|
||||
config.Orders,
|
||||
)
|
||||
if err != nil {
|
||||
|
@ -143,7 +143,7 @@ func verifySegments(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// open metabase
|
||||
metabaseDB, err := metabase.Open(ctx, log.Named("metabase"), satelliteCfg.Metainfo.DatabaseURL,
|
||||
satelliteCfg.Config.Metainfo.Metabase("satellite-core"))
|
||||
satelliteCfg.Config.Metainfo.Metabase("segment-verify"))
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
@ -190,7 +190,7 @@ func verifySegments(cmd *cobra.Command, args []string) error {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
||||
ordersService, err := orders.NewService(log.Named("orders"), signing.SignerFromFullIdentity(identity), overlay, db.Orders(), satelliteCfg.Orders)
|
||||
ordersService, err := orders.NewService(log.Named("orders"), signing.SignerFromFullIdentity(identity), overlay, orders.NewNoopDB(), satelliteCfg.Orders)
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
}
|
||||
|
@ -50,6 +50,46 @@ type DB interface {
|
||||
GetStorageNodeBandwidth(ctx context.Context, nodeID storj.NodeID, from, to time.Time) (int64, error)
|
||||
}
|
||||
|
||||
type noopDB struct {
|
||||
}
|
||||
|
||||
func (noopDB) UpdateBucketBandwidthAllocation(ctx context.Context, projectID uuid.UUID, bucketName []byte, action pb.PieceAction, amount int64, intervalStart time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (noopDB) UpdateBucketBandwidthSettle(ctx context.Context, projectID uuid.UUID, bucketName []byte, action pb.PieceAction, settledAmount, deadAmount int64, intervalStart time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (noopDB) UpdateBucketBandwidthInline(ctx context.Context, projectID uuid.UUID, bucketName []byte, action pb.PieceAction, amount int64, intervalStart time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (noopDB) UpdateBandwidthBatch(ctx context.Context, rollups []BucketBandwidthRollup) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (noopDB) UpdateStoragenodeBandwidthSettle(ctx context.Context, storageNode storj.NodeID, action pb.PieceAction, amount int64, intervalStart time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (noopDB) UpdateStoragenodeBandwidthSettleWithWindow(ctx context.Context, storageNodeID storj.NodeID, actionAmounts map[int32]int64, window time.Time) (status pb.SettlementWithWindowResponse_Status, alreadyProcessed bool, err error) {
|
||||
return pb.SettlementWithWindowResponse_ACCEPTED, false, nil
|
||||
}
|
||||
|
||||
func (noopDB) GetBucketBandwidth(ctx context.Context, projectID uuid.UUID, bucketName []byte, from, to time.Time) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (noopDB) GetStorageNodeBandwidth(ctx context.Context, nodeID storj.NodeID, from, to time.Time) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// NewNoopDB creates noop orders DB.
|
||||
func NewNoopDB() DB {
|
||||
return &noopDB{}
|
||||
}
|
||||
|
||||
// SerialDeleteOptions are option when deleting from serial tables.
|
||||
type SerialDeleteOptions struct {
|
||||
BatchSize int
|
||||
|
Loading…
Reference in New Issue
Block a user