Repair cron (#420)
* Creates cron-job for checker, adds it to captplanet and satellite * removes datarepair from satellite & captplanet run * Delete config.go * removes unused datarepair imports * adds comments to fix linter
This commit is contained in:
parent
ae38817fa3
commit
f7afafe4e1
@ -14,6 +14,7 @@ import (
|
||||
"storj.io/storj/pkg/kademlia"
|
||||
"storj.io/storj/pkg/miniogw"
|
||||
"storj.io/storj/pkg/overlay"
|
||||
"storj.io/storj/pkg/datarepair/checker"
|
||||
psserver "storj.io/storj/pkg/piecestore/rpc/server"
|
||||
"storj.io/storj/pkg/pointerdb"
|
||||
"storj.io/storj/pkg/process"
|
||||
@ -30,6 +31,7 @@ type Satellite struct {
|
||||
Kademlia kademlia.Config
|
||||
PointerDB pointerdb.Config
|
||||
Overlay overlay.Config
|
||||
Checker checker.Config
|
||||
MockOverlay struct {
|
||||
Enabled bool `default:"true" help:"if false, use real overlay"`
|
||||
Host string `default:"" help:"if set, the mock overlay will return storage nodes with this host"`
|
||||
@ -106,6 +108,7 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
|
||||
errch <- runCfg.Satellite.Identity.Run(ctx,
|
||||
runCfg.Satellite.Kademlia,
|
||||
runCfg.Satellite.PointerDB,
|
||||
runCfg.Satellite.Checker,
|
||||
o)
|
||||
}()
|
||||
|
||||
|
@ -10,9 +10,10 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
// "storj.io/storj/pkg/datarepair/checker"
|
||||
|
||||
// "storj.io/storj/pkg/datarepair/queue"
|
||||
// "storj.io/storj/pkg/datarepair/repairer"
|
||||
"storj.io/storj/pkg/datarepair/checker"
|
||||
"storj.io/storj/pkg/kademlia"
|
||||
"storj.io/storj/pkg/overlay"
|
||||
"storj.io/storj/pkg/pointerdb"
|
||||
@ -40,6 +41,7 @@ var (
|
||||
Identity provider.IdentityConfig
|
||||
Kademlia kademlia.Config
|
||||
PointerDB pointerdb.Config
|
||||
Checker checker.Config
|
||||
Overlay overlay.Config
|
||||
MockOverlay overlay.MockConfig
|
||||
// RepairQueue queue.Config
|
||||
@ -69,7 +71,7 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
|
||||
o = runCfg.MockOverlay
|
||||
}
|
||||
return runCfg.Identity.Run(process.Ctx(cmd),
|
||||
runCfg.Kademlia, o, runCfg.PointerDB)
|
||||
runCfg.Kademlia, o, runCfg.PointerDB, runCfg.Checker)
|
||||
}
|
||||
|
||||
func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
||||
|
@ -5,17 +5,48 @@ package checker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
"storj.io/storj/pkg/provider"
|
||||
)
|
||||
|
||||
var (
|
||||
mon = monkit.Package()
|
||||
// Error is a standard error class for this package.
|
||||
Error = errs.Class("checker error")
|
||||
)
|
||||
|
||||
// Config contains configurable values for checker
|
||||
type Config struct {
|
||||
// queueAddress string `help:"data repair queue address" default:"localhost:7777"`
|
||||
Interval time.Duration `help:"how frequently checker should audit segments" default:"30s"`
|
||||
}
|
||||
|
||||
// Run runs the checker with configured values
|
||||
func (c *Config) Run(ctx context.Context) (err error) {
|
||||
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
// TODO: start checker server
|
||||
zap.S().Info("Checker is starting up")
|
||||
|
||||
return err
|
||||
ticker := time.NewTicker(c.Interval)
|
||||
defer ticker.Stop()
|
||||
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
zap.S().Info("Starting segment checker service")
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return server.Run(ctx)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user