diff --git a/satellite/orders/service.go b/satellite/orders/service.go index 6351eb0ff..cd5529542 100644 --- a/satellite/orders/service.go +++ b/satellite/orders/service.go @@ -16,6 +16,7 @@ import ( "go.uber.org/zap" "storj.io/common/pb" + "storj.io/common/rpc" "storj.io/common/signing" "storj.io/common/storj" "storj.io/storj/satellite/overlay" @@ -189,7 +190,7 @@ func (service *Service) CreateGetOrderLimitsOld(ctx context.Context, bucketID [] limits = append(limits, &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), }) } @@ -282,7 +283,7 @@ func (service *Service) CreateGetOrderLimits(ctx context.Context, bucketID []byt limits = append(limits, &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), }) } @@ -390,7 +391,7 @@ func (service *Service) CreatePutOrderLimits(ctx context.Context, bucketID []byt limits[pieceNum] = &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), } pieceNum++ } @@ -474,7 +475,7 @@ func (service *Service) CreateDeleteOrderLimits(ctx context.Context, bucketID [] limits = append(limits, &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), }) } @@ -562,7 +563,7 @@ func (service *Service) CreateAuditOrderLimits(ctx context.Context, bucketID []b limits[piece.GetPieceNum()] = &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), } limitsCount++ } @@ -636,7 +637,7 @@ func (service *Service) CreateAuditOrderLimit(ctx context.Context, bucketID []by limit = &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), } err = service.saveSerial(ctx, serialNumber, bucketID, orderExpiration) @@ -731,7 +732,7 @@ func (service *Service) CreateGetRepairOrderLimits(ctx context.Context, bucketID limits[piece.GetPieceNum()] = &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), } limitsCount++ } @@ -832,7 +833,7 @@ func (service *Service) CreatePutRepairOrderLimits(ctx context.Context, bucketID limits[pieceNum] = &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), } pieceNum++ totalPiecesToRepair-- @@ -915,7 +916,7 @@ func (service *Service) CreateGracefulExitPutOrderLimit(ctx context.Context, buc limit = &pb.AddressedOrderLimit{ Limit: orderLimit, - StorageNodeAddress: node.Address, + StorageNodeAddress: lookupNodeAddress(ctx, node.Address), } err = service.saveSerial(ctx, serialNumber, bucketID, orderExpiration) @@ -964,3 +965,10 @@ func SplitBucketID(bucketID []byte) (projectID *uuid.UUID, bucketName []byte, er } return projectID, bucketName, nil } + +// lookupNodeAddress tries to resolve node address to an IP to avoid DNS lookups on the uplink side. +func lookupNodeAddress(ctx context.Context, address *pb.NodeAddress) *pb.NodeAddress { + new := *address + new.Address = rpc.LookupNodeAddress(ctx, address.Address) + return &new +}