Issues in overlay rebuild allowed to continue (#625)
* Issues in overlay rebuild allowed to continue
This commit is contained in:
parent
ace82bc834
commit
ad39201ba9
@ -25,9 +25,6 @@ const (
|
||||
OverlayBucket = "overlay"
|
||||
)
|
||||
|
||||
// ErrNodeNotFound error standardization
|
||||
var ErrNodeNotFound = errs.New("Node not found")
|
||||
|
||||
// OverlayError creates class of errors for stack traces
|
||||
var OverlayError = errs.Class("Overlay Error")
|
||||
|
||||
@ -126,25 +123,25 @@ func (o *Cache) Put(nodeID string, value pb.Node) error {
|
||||
func (o *Cache) Bootstrap(ctx context.Context) error {
|
||||
nodes, err := o.DHT.GetNodes(ctx, "", 1280)
|
||||
if err != nil {
|
||||
zap.Error(OverlayError.New("Error getting nodes from DHT: %v", err))
|
||||
return OverlayError.New("Error getting nodes from DHT: %v", err)
|
||||
}
|
||||
|
||||
for _, v := range nodes {
|
||||
found, err := o.DHT.FindNode(ctx, node.IDFromString(v.Id))
|
||||
if err != nil {
|
||||
zap.Error(ErrNodeNotFound)
|
||||
zap.L().Info("Node find failed", zap.String("nodeID", v.Id))
|
||||
continue
|
||||
}
|
||||
|
||||
n, err := proto.Marshal(&found)
|
||||
if err != nil {
|
||||
return err
|
||||
zap.L().Error("Node marshall failed", zap.String("nodeID", v.Id))
|
||||
continue
|
||||
}
|
||||
|
||||
if err := o.DB.Put(node.IDFromString(found.Id).Bytes(), n); err != nil {
|
||||
return err
|
||||
zap.L().Error("Node cache put failed", zap.String("nodeID", v.Id))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@ -163,21 +160,21 @@ func (o *Cache) Refresh(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, n := range near {
|
||||
pinged, err := o.DHT.Ping(ctx, *n)
|
||||
if err != nil {
|
||||
return err
|
||||
zap.L().Info("Node ping failed", zap.String("nodeID", n.GetId()))
|
||||
continue
|
||||
}
|
||||
|
||||
data, err := proto.Marshal(&pinged)
|
||||
if err != nil {
|
||||
return err
|
||||
zap.L().Error("Node marshall failed", zap.String("nodeID", n.GetId()))
|
||||
continue
|
||||
}
|
||||
|
||||
err = o.DB.Put(node.IDFromString(pinged.Id).Bytes(), data)
|
||||
if err != nil {
|
||||
return err
|
||||
zap.L().Error("Node cache put failed", zap.String("nodeID", n.GetId()))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,27 +183,24 @@ func (o *Cache) Refresh(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, n := range nodes {
|
||||
pinged, err := o.DHT.Ping(ctx, *n)
|
||||
if err != nil {
|
||||
zap.Error(ErrNodeNotFound)
|
||||
return err
|
||||
zap.L().Info("Node ping failed", zap.String("nodeID", n.GetId()))
|
||||
continue
|
||||
}
|
||||
|
||||
data, err := proto.Marshal(&pinged)
|
||||
if err != nil {
|
||||
return err
|
||||
zap.L().Error("Node marshall failed", zap.String("nodeID", n.GetId()))
|
||||
continue
|
||||
}
|
||||
|
||||
err = o.DB.Put(node.IDFromString(pinged.Id).Bytes(), data)
|
||||
if err != nil {
|
||||
return err
|
||||
zap.L().Error("Node cache put failed", zap.String("nodeID", n.GetId()))
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk iterates over each node in each bucket to traverse the network
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
"storj.io/storj/pkg/kademlia"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/provider"
|
||||
@ -63,7 +62,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
zap.S().Info("Starting overlay cache with BoltDB")
|
||||
zap.L().Info("Starting overlay cache with BoltDB")
|
||||
case "redis":
|
||||
db, err := strconv.Atoi(dburl.Query().Get("db"))
|
||||
if err != nil {
|
||||
@ -73,7 +72,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
zap.S().Info("Starting overlay cache with Redis")
|
||||
zap.L().Info("Starting overlay cache with Redis")
|
||||
default:
|
||||
return Error.New("database scheme not supported: %s", dburl.Scheme)
|
||||
}
|
||||
@ -95,7 +94,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (
|
||||
case <-ticker.C:
|
||||
err := cache.Refresh(ctx)
|
||||
if err != nil {
|
||||
zap.S().Error("Error with cache refresh: ", err)
|
||||
zap.L().Error("Error with cache refresh: ", zap.Error(err))
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user