satellite/orders: don't panic (#2331)
This commit is contained in:
parent
05a283f331
commit
caa2fcf62b
@ -104,8 +104,6 @@ func TestDialer(t *testing.T) {
|
||||
group.Go(func() error {
|
||||
for _, target := range peers {
|
||||
errTag := fmt.Errorf("lookup peer:%s target:%s", peer.ID(), target.ID())
|
||||
peer.Local().Type.DPanicOnInvalid("test client peer")
|
||||
target.Local().Type.DPanicOnInvalid("test client target")
|
||||
|
||||
results, err := dialer.Lookup(ctx, self.Local().Node, peer.Local().Node, target.Local().Node)
|
||||
if err != nil {
|
||||
@ -146,7 +144,7 @@ func TestDialer(t *testing.T) {
|
||||
peer := peer
|
||||
group.Go(func() error {
|
||||
errTag := fmt.Errorf("invalid lookup peer:%s target:%s", peer.ID(), target)
|
||||
peer.Local().Type.DPanicOnInvalid("peer info")
|
||||
|
||||
results, err := dialer.Lookup(ctx, self.Local().Node, peer.Local().Node, pb.Node{Id: target})
|
||||
if err != nil {
|
||||
return errs.Combine(errTag, err)
|
||||
@ -277,9 +275,6 @@ func TestSlowDialerHasTimeout(t *testing.T) {
|
||||
peer := peer
|
||||
group.Go(func() error {
|
||||
for _, target := range peers {
|
||||
peer.Local().Type.DPanicOnInvalid("test client peer")
|
||||
target.Local().Type.DPanicOnInvalid("test client target")
|
||||
|
||||
_, err := dialer.Lookup(ctx, self.Local().Node, peer.Local().Node, target.Local().Node)
|
||||
if !transport.Error.Has(err) || errs.Unwrap(err) != context.DeadlineExceeded {
|
||||
return errs.New("invalid error: %v (peer:%s target:%s)", err, peer.ID(), target.ID())
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/storj/pkg/storj"
|
||||
)
|
||||
@ -63,15 +62,6 @@ func CopyNode(src *Node) (dst *Node) {
|
||||
return &node
|
||||
}
|
||||
|
||||
// DPanicOnInvalid panics if NodeType is invalid if zap is in development mode,
|
||||
// otherwise it logs.
|
||||
func (nt NodeType) DPanicOnInvalid(from string) {
|
||||
// TODO: Remove all references
|
||||
if nt == NodeType_INVALID {
|
||||
zap.L().DPanic("INVALID NODE TYPE: " + from)
|
||||
}
|
||||
}
|
||||
|
||||
// AddressEqual compares two node addresses
|
||||
func AddressEqual(a1, a2 *NodeAddress) bool {
|
||||
if a1 == nil && a2 == nil {
|
||||
|
@ -152,10 +152,6 @@ func (service *Service) CreateGetOrderLimits(ctx context.Context, uplink *identi
|
||||
continue
|
||||
}
|
||||
|
||||
if node != nil {
|
||||
node.Type.DPanicOnInvalid("order service get order limits")
|
||||
}
|
||||
|
||||
if node.Disqualified != nil {
|
||||
service.log.Debug("node is disqualified", zap.Stringer("ID", node.Id))
|
||||
combinedErrs = errs.Combine(combinedErrs, overlay.ErrNodeDisqualified.New(node.Id.String()))
|
||||
@ -302,15 +298,11 @@ func (service *Service) CreateDeleteOrderLimits(ctx context.Context, uplink *ide
|
||||
for _, piece := range pointer.GetRemote().GetRemotePieces() {
|
||||
node, err := service.cache.Get(ctx, piece.NodeId)
|
||||
if err != nil {
|
||||
service.log.Debug("error getting node from overlay cache", zap.Error(err))
|
||||
service.log.Error("error getting node from overlay cache", zap.Error(err))
|
||||
combinedErrs = errs.Combine(combinedErrs, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if node != nil {
|
||||
node.Type.DPanicOnInvalid("order service delete order limits")
|
||||
}
|
||||
|
||||
if node.Disqualified != nil {
|
||||
service.log.Debug("node is disqualified", zap.Stringer("ID", node.Id))
|
||||
combinedErrs = errs.Combine(combinedErrs, overlay.ErrNodeDisqualified.New(node.Id.String()))
|
||||
@ -399,10 +391,6 @@ func (service *Service) CreateAuditOrderLimits(ctx context.Context, auditor *ide
|
||||
continue
|
||||
}
|
||||
|
||||
if node != nil {
|
||||
node.Type.DPanicOnInvalid("order service audit order limits")
|
||||
}
|
||||
|
||||
if node.Disqualified != nil {
|
||||
service.log.Debug("node is disqualified", zap.Stringer("ID", node.Id))
|
||||
combinedErrs = errs.Combine(combinedErrs, overlay.ErrNodeDisqualified.New(node.Id.String()))
|
||||
@ -479,10 +467,6 @@ func (service *Service) CreateAuditOrderLimit(ctx context.Context, auditor *iden
|
||||
return nil, Error.Wrap(err)
|
||||
}
|
||||
|
||||
if node != nil {
|
||||
node.Type.DPanicOnInvalid("order service audit order limits")
|
||||
}
|
||||
|
||||
if node.Disqualified != nil {
|
||||
return nil, overlay.ErrNodeDisqualified.New(nodeID.String())
|
||||
}
|
||||
@ -562,10 +546,6 @@ func (service *Service) CreateGetRepairOrderLimits(ctx context.Context, repairer
|
||||
continue
|
||||
}
|
||||
|
||||
if node != nil {
|
||||
node.Type.DPanicOnInvalid("order service get repair order limits")
|
||||
}
|
||||
|
||||
if node.Disqualified != nil {
|
||||
service.log.Debug("node is disqualified", zap.Stringer("ID", node.Id))
|
||||
combinedErrs = errs.Combine(combinedErrs, overlay.ErrNodeDisqualified.New(node.Id.String()))
|
||||
|
Loading…
Reference in New Issue
Block a user