all: use DialNodeURL throughout the codebase

Change-Id: Iaf9ae3aeef7305c937f2660c929744db2d88776c
This commit is contained in:
Egon Elbre 2020-05-19 18:49:13 +03:00 committed by Stefan Benten
parent 963db8c738
commit ed627144ed
24 changed files with 103 additions and 108 deletions

6
go.mod
View File

@ -23,7 +23,7 @@ require (
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
github.com/shopspring/decimal v0.0.0-20200105231215-408a2507e114 github.com/shopspring/decimal v0.0.0-20200105231215-408a2507e114
github.com/sirupsen/logrus v1.5.0 // indirect github.com/sirupsen/logrus v1.5.0 // indirect
github.com/spacemonkeygo/monkit/v3 v3.0.6 github.com/spacemonkeygo/monkit/v3 v3.0.7-0.20200515175308-072401d8c752
github.com/spf13/cast v1.3.0 github.com/spf13/cast v1.3.0
github.com/spf13/cobra v0.0.6 github.com/spf13/cobra v0.0.6
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
@ -40,9 +40,9 @@ require (
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 golang.org/x/time v0.0.0-20191024005414-555d28b269f0
golang.org/x/tools v0.0.0-20200428211428-0c9eba77bc32 // indirect golang.org/x/tools v0.0.0-20200428211428-0c9eba77bc32 // indirect
storj.io/common v0.0.0-20200513105542-a376f4c68993 storj.io/common v0.0.0-20200519144636-6a729faf9037
storj.io/drpc v0.0.12 storj.io/drpc v0.0.12
storj.io/monkit-jaeger v0.0.0-20200424180155-d5f5530ea079 storj.io/monkit-jaeger v0.0.0-20200424180155-d5f5530ea079
storj.io/private v0.0.0-20200504130741-565a173f6d33 storj.io/private v0.0.0-20200504130741-565a173f6d33
storj.io/uplink v1.0.5 storj.io/uplink v1.0.6-0.20200519150128-ca493a2906a0
) )

6
go.sum
View File

@ -341,6 +341,8 @@ github.com/spacemonkeygo/monkit/v3 v3.0.6-0.20200417171149-7f4a2b305c34 h1:N6DG0
github.com/spacemonkeygo/monkit/v3 v3.0.6-0.20200417171149-7f4a2b305c34/go.mod h1:kj1ViJhlyADa7DiA4xVnTuPA46lFKbM7mxQTrXCuJP4= github.com/spacemonkeygo/monkit/v3 v3.0.6-0.20200417171149-7f4a2b305c34/go.mod h1:kj1ViJhlyADa7DiA4xVnTuPA46lFKbM7mxQTrXCuJP4=
github.com/spacemonkeygo/monkit/v3 v3.0.6 h1:BKPrEaLokVAxlwHkD7jawViBa/IU9/bgXbZLWgjbdSM= github.com/spacemonkeygo/monkit/v3 v3.0.6 h1:BKPrEaLokVAxlwHkD7jawViBa/IU9/bgXbZLWgjbdSM=
github.com/spacemonkeygo/monkit/v3 v3.0.6/go.mod h1:kj1ViJhlyADa7DiA4xVnTuPA46lFKbM7mxQTrXCuJP4= github.com/spacemonkeygo/monkit/v3 v3.0.6/go.mod h1:kj1ViJhlyADa7DiA4xVnTuPA46lFKbM7mxQTrXCuJP4=
github.com/spacemonkeygo/monkit/v3 v3.0.7-0.20200515175308-072401d8c752 h1:WcQDknqg0qajLNYKv3mXgbkWlYs5rPgZehGJFWePHVI=
github.com/spacemonkeygo/monkit/v3 v3.0.7-0.20200515175308-072401d8c752/go.mod h1:kj1ViJhlyADa7DiA4xVnTuPA46lFKbM7mxQTrXCuJP4=
github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a h1:8+cCjxhToanKmxLIbuyBNe2EnpgwhiivsIaRJstDRFA= github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a h1:8+cCjxhToanKmxLIbuyBNe2EnpgwhiivsIaRJstDRFA=
github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a/go.mod h1:ul4bvvnCOPZgq8w0nTkSmWVg/hauVpFS97Am1YM1XXo= github.com/spacemonkeygo/monotime v0.0.0-20180824235756-e3f48a95f98a/go.mod h1:ul4bvvnCOPZgq8w0nTkSmWVg/hauVpFS97Am1YM1XXo=
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU= github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU=
@ -642,6 +644,8 @@ storj.io/common v0.0.0-20200429074521-4ba140e4b747 h1:Ne1x0M80uNyN6tHIs15CGJqHbr
storj.io/common v0.0.0-20200429074521-4ba140e4b747/go.mod h1:lfsaMdtHwrUOtSYkw73meCyZMUYiaFBKVqx6zgeSz2o= storj.io/common v0.0.0-20200429074521-4ba140e4b747/go.mod h1:lfsaMdtHwrUOtSYkw73meCyZMUYiaFBKVqx6zgeSz2o=
storj.io/common v0.0.0-20200513105542-a376f4c68993 h1:sBCwa8bxzi8kc48iVX6SFGPmlhC9G4EmA4hPkyDpGww= storj.io/common v0.0.0-20200513105542-a376f4c68993 h1:sBCwa8bxzi8kc48iVX6SFGPmlhC9G4EmA4hPkyDpGww=
storj.io/common v0.0.0-20200513105542-a376f4c68993/go.mod h1:hqUDJlDHU1kZuZmfLohWgGa0Cf3pL1IH8DsxLCsamNQ= storj.io/common v0.0.0-20200513105542-a376f4c68993/go.mod h1:hqUDJlDHU1kZuZmfLohWgGa0Cf3pL1IH8DsxLCsamNQ=
storj.io/common v0.0.0-20200519144636-6a729faf9037 h1:CbUn4bph75bE4icyP8gyw+TcrFxWmu2Xzh0Y8OcP+x0=
storj.io/common v0.0.0-20200519144636-6a729faf9037/go.mod h1:hqUDJlDHU1kZuZmfLohWgGa0Cf3pL1IH8DsxLCsamNQ=
storj.io/drpc v0.0.11 h1:6vLxfpSbwCLtqzAoXzXx/SxBqBtbzbmquXPqfcWKqfw= storj.io/drpc v0.0.11 h1:6vLxfpSbwCLtqzAoXzXx/SxBqBtbzbmquXPqfcWKqfw=
storj.io/drpc v0.0.11 h1:6vLxfpSbwCLtqzAoXzXx/SxBqBtbzbmquXPqfcWKqfw= storj.io/drpc v0.0.11 h1:6vLxfpSbwCLtqzAoXzXx/SxBqBtbzbmquXPqfcWKqfw=
storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw= storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw=
@ -654,3 +658,5 @@ storj.io/private v0.0.0-20200504130741-565a173f6d33 h1:IX88Sr6q32yrmt94aNgiwem4U
storj.io/private v0.0.0-20200504130741-565a173f6d33/go.mod h1:fU2XXdFHiWincQagQjvIfE2+ge9JMAcQAeYqiEXb7ZM= storj.io/private v0.0.0-20200504130741-565a173f6d33/go.mod h1:fU2XXdFHiWincQagQjvIfE2+ge9JMAcQAeYqiEXb7ZM=
storj.io/uplink v1.0.5 h1:RH6LUZQPOJZ01JpM0YmghDu5xyex5gyn32NSCzsPSr4= storj.io/uplink v1.0.5 h1:RH6LUZQPOJZ01JpM0YmghDu5xyex5gyn32NSCzsPSr4=
storj.io/uplink v1.0.5/go.mod h1:GkChEUgHFuUR2WNpqFw3NeqglXz6/zp6n5Rxt0IVfHw= storj.io/uplink v1.0.5/go.mod h1:GkChEUgHFuUR2WNpqFw3NeqglXz6/zp6n5Rxt0IVfHw=
storj.io/uplink v1.0.6-0.20200519150128-ca493a2906a0 h1:0YfZBEmrl9AuIkIMfN2414vQB0qy5t9heFxsvKZxvEA=
storj.io/uplink v1.0.6-0.20200519150128-ca493a2906a0/go.mod h1:E4yRIKl1Py+DK/BKp6hDM2uyEeJpP0tF981kmY7ke8Y=

View File

@ -47,7 +47,7 @@ func TestPutGetList(t *testing.T) {
UplinkCount: 1}, UplinkCount: 1},
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
apiKey := planet.Uplinks[0].APIKey[planet.Satellites[0].ID()].Serialize() apiKey := planet.Uplinks[0].APIKey[planet.Satellites[0].ID()].Serialize()
satelliteAddr := planet.Satellites[0].Local().Address.Address satelliteAddr := planet.Satellites[0].Addr()
tests := []putGetListTest{ tests := []putGetListTest{
{ {

View File

@ -33,10 +33,10 @@ func TestBasic(t *testing.T) {
} }
for _, sat := range planet.Satellites { for _, sat := range planet.Satellites {
satellite := sat.Local().Node
for _, sn := range planet.StorageNodes { for _, sn := range planet.StorageNodes {
node := sn.Local() node := sn.Local()
conn, err := sn.Dialer.DialNode(ctx, &satellite) conn, err := sn.Dialer.DialNodeURL(ctx, sat.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
_, err = pb.NewDRPCNodeClient(conn).CheckIn(ctx, &pb.CheckInRequest{ _, err = pb.NewDRPCNodeClient(conn).CheckIn(ctx, &pb.CheckInRequest{

View File

@ -14,7 +14,6 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
"storj.io/common/identity/testidentity" "storj.io/common/identity/testidentity"
"storj.io/common/pb"
"storj.io/common/peertls/tlsopts" "storj.io/common/peertls/tlsopts"
"storj.io/common/rpc" "storj.io/common/rpc"
"storj.io/common/storj" "storj.io/common/storj"
@ -24,7 +23,7 @@ import (
"storj.io/storj/storagenode" "storj.io/storj/storagenode"
) )
func TestDialNode(t *testing.T) { func TestDialNodeURL(t *testing.T) {
testplanet.Run(t, testplanet.Config{ testplanet.Run(t, testplanet.Config{
SatelliteCount: 0, StorageNodeCount: 2, UplinkCount: 0, SatelliteCount: 0, StorageNodeCount: 2, UplinkCount: 0,
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
@ -53,39 +52,27 @@ func TestDialNode(t *testing.T) {
unsignedDialer := rpc.NewDefaultDialer(unsignedClientOpts) unsignedDialer := rpc.NewDefaultDialer(unsignedClientOpts)
t.Run("DialNode with invalid targets", func(t *testing.T) { t.Run("DialNodeURL with invalid targets", func(t *testing.T) {
targets := []*pb.Node{ targets := []storj.NodeURL{
{ {
Id: storj.NodeID{}, ID: storj.NodeID{},
Address: nil, Address: "",
}, },
{ {
Id: storj.NodeID{}, ID: storj.NodeID{123},
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
},
},
{
Id: storj.NodeID{123},
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: "127.0.0.1:100", Address: "127.0.0.1:100",
}, },
},
{ {
Id: storj.NodeID{}, ID: storj.NodeID{},
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: planet.StorageNodes[1].Addr(), Address: planet.StorageNodes[1].Addr(),
}, },
},
} }
for _, target := range targets { for _, target := range targets {
tag := fmt.Sprintf("%+v", target) tag := fmt.Sprintf("%+v", target)
timedCtx, cancel := context.WithTimeout(ctx, time.Second) timedCtx, cancel := context.WithTimeout(ctx, time.Second)
conn, err := dialer.DialNode(timedCtx, target) conn, err := dialer.DialNodeURL(timedCtx, target)
cancel() cancel()
assert.Error(t, err, tag) assert.Error(t, err, tag)
assert.Nil(t, conn, tag) assert.Nil(t, conn, tag)
@ -93,16 +80,8 @@ func TestDialNode(t *testing.T) {
}) })
t.Run("DialNode with valid signed target", func(t *testing.T) { t.Run("DialNode with valid signed target", func(t *testing.T) {
target := &pb.Node{
Id: planet.StorageNodes[1].ID(),
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: planet.StorageNodes[1].Addr(),
},
}
timedCtx, cancel := context.WithTimeout(ctx, time.Second) timedCtx, cancel := context.WithTimeout(ctx, time.Second)
conn, err := dialer.DialNode(timedCtx, target) conn, err := dialer.DialNodeURL(timedCtx, planet.StorageNodes[1].NodeURL())
cancel() cancel()
assert.NoError(t, err) assert.NoError(t, err)
@ -112,16 +91,8 @@ func TestDialNode(t *testing.T) {
}) })
t.Run("DialNode with unsigned identity", func(t *testing.T) { t.Run("DialNode with unsigned identity", func(t *testing.T) {
target := &pb.Node{
Id: planet.StorageNodes[1].ID(),
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: planet.StorageNodes[1].Addr(),
},
}
timedCtx, cancel := context.WithTimeout(ctx, time.Second) timedCtx, cancel := context.WithTimeout(ctx, time.Second)
conn, err := unsignedDialer.DialNode(timedCtx, target) conn, err := unsignedDialer.DialNodeURL(timedCtx, planet.StorageNodes[1].NodeURL())
cancel() cancel()
assert.NotNil(t, conn) assert.NotNil(t, conn)
@ -181,20 +152,12 @@ func TestDialNode_BadServerCertificate(t *testing.T) {
dialer := rpc.NewDefaultDialer(tlsOptions) dialer := rpc.NewDefaultDialer(tlsOptions)
t.Run("DialNode with bad server certificate", func(t *testing.T) { t.Run("DialNodeURL with bad server certificate", func(t *testing.T) {
target := &pb.Node{
Id: planet.StorageNodes[1].ID(),
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: planet.StorageNodes[1].Addr(),
},
}
timedCtx, cancel := context.WithTimeout(ctx, time.Second) timedCtx, cancel := context.WithTimeout(ctx, time.Second)
conn, err := dialer.DialNode(timedCtx, target) conn, err := dialer.DialNodeURL(timedCtx, planet.StorageNodes[1].NodeURL())
cancel() cancel()
tag := fmt.Sprintf("%+v", target) tag := fmt.Sprintf("%+v", planet.StorageNodes[1].NodeURL())
assert.Nil(t, conn, tag) assert.Nil(t, conn, tag)
require.Error(t, err, tag) require.Error(t, err, tag)
assert.Contains(t, err.Error(), "not signed by any CA in the whitelist") assert.Contains(t, err.Error(), "not signed by any CA in the whitelist")
@ -202,7 +165,7 @@ func TestDialNode_BadServerCertificate(t *testing.T) {
t.Run("DialAddress with bad server certificate", func(t *testing.T) { t.Run("DialAddress with bad server certificate", func(t *testing.T) {
timedCtx, cancel := context.WithTimeout(ctx, time.Second) timedCtx, cancel := context.WithTimeout(ctx, time.Second)
conn, err := dialer.DialAddressID(timedCtx, planet.StorageNodes[1].Addr(), planet.StorageNodes[1].ID()) conn, err := dialer.DialNodeURL(timedCtx, planet.StorageNodes[1].NodeURL())
cancel() cancel()
assert.Nil(t, conn) assert.Nil(t, conn)

View File

@ -22,7 +22,7 @@ func TestOptions_ServerOption_Peer_CA_Whitelist(t *testing.T) {
testplanet.Run(t, testplanet.Config{ testplanet.Run(t, testplanet.Config{
SatelliteCount: 0, StorageNodeCount: 2, UplinkCount: 0, SatelliteCount: 0, StorageNodeCount: 2, UplinkCount: 0,
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
target := planet.StorageNodes[1].Local() sn := planet.StorageNodes[1]
testidentity.CompleteIdentityVersionsTest(t, func(t *testing.T, version storj.IDVersion, ident *identity.FullIdentity) { testidentity.CompleteIdentityVersionsTest(t, func(t *testing.T, version storj.IDVersion, ident *identity.FullIdentity) {
tlsOptions, err := tlsopts.NewOptions(ident, tlsopts.Config{ tlsOptions, err := tlsopts.NewOptions(ident, tlsopts.Config{
PeerIDVersions: "*", PeerIDVersions: "*",
@ -31,7 +31,7 @@ func TestOptions_ServerOption_Peer_CA_Whitelist(t *testing.T) {
dialer := rpc.NewDefaultDialer(tlsOptions) dialer := rpc.NewDefaultDialer(tlsOptions)
conn, err := dialer.DialNode(ctx, &target.Node) conn, err := dialer.DialNodeURL(ctx, sn.NodeURL())
assert.NotNil(t, conn) assert.NotNil(t, conn)
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -216,13 +216,12 @@ func (client *Uplink) Shutdown() error { return nil }
// DialMetainfo dials destination with apikey and returns metainfo Client // DialMetainfo dials destination with apikey and returns metainfo Client
func (client *Uplink) DialMetainfo(ctx context.Context, destination Peer, apikey *macaroon.APIKey) (*metainfo.Client, error) { func (client *Uplink) DialMetainfo(ctx context.Context, destination Peer, apikey *macaroon.APIKey) (*metainfo.Client, error) {
return metainfo.Dial(ctx, client.Dialer, destination.Addr(), apikey, "Test/1.0") return metainfo.DialNodeURL(ctx, client.Dialer, destination.NodeURL().String(), apikey, "Test/1.0")
} }
// DialPiecestore dials destination storagenode and returns a piecestore client. // DialPiecestore dials destination storagenode and returns a piecestore client.
func (client *Uplink) DialPiecestore(ctx context.Context, destination Peer) (*piecestore.Client, error) { func (client *Uplink) DialPiecestore(ctx context.Context, destination Peer) (*piecestore.Client, error) {
node := destination.Local() return piecestore.DialNodeURL(ctx, client.Dialer, destination.NodeURL(), client.Log.Named("uplink>piecestore"), piecestore.DefaultConfig)
return piecestore.Dial(ctx, client.Dialer, &node.Node, client.Log.Named("uplink>piecestore"), piecestore.DefaultConfig)
} }
// Upload data to specific satellite // Upload data to specific satellite

View File

@ -637,11 +637,12 @@ func (verifier *Verifier) GetShare(ctx context.Context, limit *pb.AddressedOrder
defer cancel() defer cancel()
} }
storageNodeID := limit.GetLimit().StorageNodeId nodeurl := storj.NodeURL{
log := verifier.log.Named(storageNodeID.String()) ID: limit.GetLimit().StorageNodeId,
target := &pb.Node{Id: storageNodeID, Address: limit.GetStorageNodeAddress()} Address: limit.GetStorageNodeAddress().Address,
}
ps, err := piecestore.Dial(timedCtx, verifier.dialer, target, log, piecestore.DefaultConfig) log := verifier.log.Named(nodeurl.ID.String())
ps, err := piecestore.DialNodeURL(timedCtx, verifier.dialer, nodeurl, log, piecestore.DefaultConfig)
if err != nil { if err != nil {
return Share{}, Error.Wrap(err) return Share{}, Error.Wrap(err)
} }
@ -669,7 +670,7 @@ func (verifier *Verifier) GetShare(ctx context.Context, limit *pb.AddressedOrder
return Share{ return Share{
Error: nil, Error: nil,
PieceNum: pieceNum, PieceNum: pieceNum,
NodeID: storageNodeID, NodeID: nodeurl.ID,
Data: buf, Data: buf,
}, nil }, nil
} }

View File

@ -18,7 +18,10 @@ type client struct {
// dialNode dials the target contact endpoint // dialNode dials the target contact endpoint
func dialNode(ctx context.Context, dialer rpc.Dialer, address string, id storj.NodeID) (*client, error) { func dialNode(ctx context.Context, dialer rpc.Dialer, address string, id storj.NodeID) (*client, error) {
conn, err := dialer.DialAddressID(ctx, address, id) conn, err := dialer.DialNodeURL(ctx, storj.NodeURL{
ID: id,
Address: address,
})
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -162,7 +162,12 @@ func (service *Service) sendRetainRequest(ctx context.Context, id storj.NodeID,
defer cancel() defer cancel()
} }
client, err := piecestore.Dial(ctx, service.dialer, &dossier.Node, log, piecestore.DefaultConfig) nodeurl := storj.NodeURL{
ID: id,
Address: dossier.Address.Address,
}
client, err := piecestore.DialNodeURL(ctx, service.dialer, nodeurl, log, piecestore.DefaultConfig)
if err != nil { if err != nil {
return Error.Wrap(err) return Error.Wrap(err)
} }

View File

@ -177,7 +177,7 @@ func TestConcurrentConnections(t *testing.T) {
for i := 0; i < concurrentCalls; i++ { for i := 0; i < concurrentCalls; i++ {
group.Go(func() (err error) { group.Go(func() (err error) {
// connect to satellite so we initiate the exit. // connect to satellite so we initiate the exit.
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer func() { defer func() {
err = errs.Combine(err, conn.Close()) err = errs.Combine(err, conn.Close())
@ -199,7 +199,7 @@ func TestConcurrentConnections(t *testing.T) {
} }
// connect to satellite so we initiate the exit ("main" call) // connect to satellite so we initiate the exit ("main" call)
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -400,7 +400,7 @@ func TestExitDisqualifiedNodeFailOnStart(t *testing.T) {
err := satellite.DB.OverlayCache().DisqualifyNode(ctx, exitingNode.ID()) err := satellite.DB.OverlayCache().DisqualifyNode(ctx, exitingNode.ID())
require.NoError(t, err) require.NoError(t, err)
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -947,7 +947,7 @@ func TestExitDisabled(t *testing.T) {
require.Nil(t, satellite.GracefulExit.Chore) require.Nil(t, satellite.GracefulExit.Chore)
require.Nil(t, satellite.GracefulExit.Endpoint) require.Nil(t, satellite.GracefulExit.Endpoint)
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -1023,7 +1023,7 @@ func TestPointerChangedOrDeleted(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// reconnect to the satellite. // reconnect to the satellite.
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -1260,7 +1260,7 @@ func TestFailureStorageNodeIgnoresTransferMessages(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// connect to satellite so we initiate the exit. // connect to satellite so we initiate the exit.
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -1388,7 +1388,7 @@ func TestIneligibleNodeAge(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// connect to satellite so we initiate the exit. // connect to satellite so we initiate the exit.
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -1446,7 +1446,7 @@ func testTransfers(t *testing.T, objects int, verifier func(t *testing.T, ctx *t
require.NoError(t, err) require.NoError(t, err)
// connect to satellite so we initiate the exit. // connect to satellite so we initiate the exit.
conn, err := exitingNode.Dialer.DialAddressID(ctx, satellite.Addr(), satellite.Identity.ID) conn, err := exitingNode.Dialer.DialNodeURL(ctx, satellite.NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)

View File

@ -150,7 +150,10 @@ func batchJobs(jobs []Job, maxBatchSize int) (pieces []storj.PieceID, promises [
} }
func dialPieceStore(ctx context.Context, dialer rpc.Dialer, target *pb.Node) (pb.DRPCPiecestoreClient, *rpc.Conn, error) { func dialPieceStore(ctx context.Context, dialer rpc.Dialer, target *pb.Node) (pb.DRPCPiecestoreClient, *rpc.Conn, error) {
conn, err := dialer.DialNode(ctx, target) conn, err := dialer.DialNodeURL(ctx, storj.NodeURL{
ID: target.Id,
Address: target.Address.Address,
})
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -183,5 +183,5 @@ func (service *Service) referralManagerConn(ctx context.Context) (*rpc.Conn, err
return nil, errs.New("missing referral manager url configuration") return nil, errs.New("missing referral manager url configuration")
} }
return service.dialer.DialAddressID(ctx, service.config.ReferralManagerURL.Address, service.config.ReferralManagerURL.ID) return service.dialer.DialNodeURL(ctx, service.config.ReferralManagerURL)
} }

View File

@ -52,9 +52,9 @@ func NewECRepairer(log *zap.Logger, dialer rpc.Dialer, satelliteSignee signing.S
} }
} }
func (ec *ECRepairer) dialPiecestore(ctx context.Context, n *pb.Node) (*piecestore.Client, error) { func (ec *ECRepairer) dialPiecestore(ctx context.Context, n storj.NodeURL) (*piecestore.Client, error) {
logger := ec.log.Named(n.Id.String()) logger := ec.log.Named(n.ID.String())
return piecestore.Dial(ctx, ec.dialer, n, logger, piecestore.DefaultConfig) return piecestore.DialNodeURL(ctx, ec.dialer, n, logger, piecestore.DefaultConfig)
} }
// Get downloads pieces from storagenodes using the provided order limits, and decodes those pieces into a segment. // Get downloads pieces from storagenodes using the provided order limits, and decodes those pieces into a segment.
@ -174,9 +174,9 @@ func (ec *ECRepairer) downloadAndVerifyPiece(ctx context.Context, limit *pb.Addr
downloadCtx, cancel := context.WithTimeout(ctx, ec.downloadTimeout) downloadCtx, cancel := context.WithTimeout(ctx, ec.downloadTimeout)
defer cancel() defer cancel()
ps, err := ec.dialPiecestore(downloadCtx, &pb.Node{ ps, err := ec.dialPiecestore(downloadCtx, storj.NodeURL{
Id: limit.GetLimit().StorageNodeId, ID: limit.GetLimit().StorageNodeId,
Address: limit.GetStorageNodeAddress(), Address: limit.GetStorageNodeAddress().Address,
}) })
if err != nil { if err != nil {
return nil, err return nil, err
@ -411,9 +411,9 @@ func (ec *ECRepairer) putPiece(ctx, parent context.Context, limit *pb.AddressedO
storageNodeID := limit.GetLimit().StorageNodeId storageNodeID := limit.GetLimit().StorageNodeId
pieceID := limit.GetLimit().PieceId pieceID := limit.GetLimit().PieceId
ps, err := ec.dialPiecestore(ctx, &pb.Node{ ps, err := ec.dialPiecestore(ctx, storj.NodeURL{
Id: storageNodeID, ID: storageNodeID,
Address: limit.GetStorageNodeAddress(), Address: limit.GetStorageNodeAddress().Address,
}) })
if err != nil { if err != nil {
ec.log.Debug("Failed dialing for putting piece to node", ec.log.Debug("Failed dialing for putting piece to node",

View File

@ -17,9 +17,7 @@ func TestVouchers(t *testing.T) {
testplanet.Run(t, testplanet.Config{ testplanet.Run(t, testplanet.Config{
SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 0, SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 0,
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
satellite := planet.Satellites[0].Local().Node conn, err := planet.StorageNodes[0].Dialer.DialNodeURL(ctx, planet.Satellites[0].NodeURL())
conn, err := planet.StorageNodes[0].Dialer.DialNode(ctx, &satellite)
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)

View File

@ -19,10 +19,9 @@ func TestStoragenodeContactEndpoint(t *testing.T) {
testplanet.Run(t, testplanet.Config{ testplanet.Run(t, testplanet.Config{
SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 0, SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 0,
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
nodeDossier := planet.StorageNodes[0].Local()
pingStats := planet.StorageNodes[0].Contact.PingStats pingStats := planet.StorageNodes[0].Contact.PingStats
conn, err := planet.Satellites[0].Dialer.DialNode(ctx, &nodeDossier.Node) conn, err := planet.Satellites[0].Dialer.DialNodeURL(ctx, planet.StorageNodes[0].NodeURL())
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)

View File

@ -114,7 +114,10 @@ func (service *Service) pingSatelliteOnce(ctx context.Context, id storj.NodeID)
return errPingSatellite.Wrap(err) return errPingSatellite.Wrap(err)
} }
conn, err := service.dialer.DialAddressID(ctx, address, id) conn, err := service.dialer.DialNodeURL(ctx, storj.NodeURL{
ID: id,
Address: address,
})
if err != nil { if err != nil {
return errPingSatellite.Wrap(err) return errPingSatellite.Wrap(err)
} }

View File

@ -65,7 +65,10 @@ func (worker *Worker) Run(ctx context.Context, done func()) (err error) {
worker.log.Debug("running worker") worker.log.Debug("running worker")
conn, err := worker.dialer.DialAddressID(ctx, worker.satelliteAddr, worker.satelliteID) conn, err := worker.dialer.DialNodeURL(ctx, storj.NodeURL{
ID: worker.satelliteID,
Address: worker.satelliteAddr,
})
if err != nil { if err != nil {
return errs.Wrap(err) return errs.Wrap(err)
} }

View File

@ -309,7 +309,10 @@ func (service *Service) dial(ctx context.Context, satelliteID storj.NodeID) (_ *
return nil, errs.New("unable to find satellite %s: %w", satelliteID, err) return nil, errs.New("unable to find satellite %s: %w", satelliteID, err)
} }
conn, err := service.dialer.DialAddressID(ctx, address, satelliteID) conn, err := service.dialer.DialNodeURL(ctx, storj.NodeURL{
ID: satelliteID,
Address: address,
})
if err != nil { if err != nil {
return nil, errs.New("unable to connect to the satellite %s: %w", satelliteID, err) return nil, errs.New("unable to connect to the satellite %s: %w", satelliteID, err)
} }

View File

@ -150,7 +150,10 @@ func (s *Service) dial(ctx context.Context, satelliteID storj.NodeID) (_ *Client
return nil, errs.New("unable to find satellite %s: %w", satelliteID, err) return nil, errs.New("unable to find satellite %s: %w", satelliteID, err)
} }
conn, err := s.dialer.DialAddressID(ctx, address, satelliteID) conn, err := s.dialer.DialNodeURL(ctx, storj.NodeURL{
ID: satelliteID,
Address: address,
})
if err != nil { if err != nil {
return nil, errs.New("unable to connect to the satellite %s: %w", satelliteID, err) return nil, errs.New("unable to connect to the satellite %s: %w", satelliteID, err)
} }

View File

@ -276,7 +276,10 @@ func (service *Service) settle(ctx context.Context, log *zap.Logger, satelliteID
return OrderError.New("unable to get satellite address: %w", err) return OrderError.New("unable to get satellite address: %w", err)
} }
conn, err := service.dialer.DialAddressID(ctx, address, satelliteID) conn, err := service.dialer.DialNodeURL(ctx, storj.NodeURL{
ID: satelliteID,
Address: address,
})
if err != nil { if err != nil {
return OrderError.New("unable to connect to the satellite: %w", err) return OrderError.New("unable to connect to the satellite: %w", err)
} }

View File

@ -306,7 +306,7 @@ func TestDelete(t *testing.T) {
uploadPiece(t, ctx, pieceID, planet.StorageNodes[0], planet.Uplinks[0], planet.Satellites[0]) uploadPiece(t, ctx, pieceID, planet.StorageNodes[0], planet.Uplinks[0], planet.Satellites[0])
nodeurl := planet.StorageNodes[0].NodeURL() nodeurl := planet.StorageNodes[0].NodeURL()
conn, err := planet.Uplinks[0].Dialer.DialAddressID(ctx, nodeurl.Address, nodeurl.ID) conn, err := planet.Uplinks[0].Dialer.DialNodeURL(ctx, nodeurl)
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -376,7 +376,7 @@ func TestDeletePieces(t *testing.T) {
storagenode := planet.StorageNodes[0] storagenode := planet.StorageNodes[0]
nodeurl := storagenode.NodeURL() nodeurl := storagenode.NodeURL()
conn, err := planet.Satellites[0].Dialer.DialAddressID(ctx, nodeurl.Address, nodeurl.ID) conn, err := planet.Satellites[0].Dialer.DialNodeURL(ctx, nodeurl)
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
@ -446,7 +446,7 @@ func TestDeletePieces(t *testing.T) {
}) })
t.Run("error: permission denied", func(t *testing.T) { t.Run("error: permission denied", func(t *testing.T) {
conn, err := planet.Uplinks[0].Dialer.DialAddressID(ctx, nodeurl.Address, nodeurl.ID) conn, err := planet.Uplinks[0].Dialer.DialNodeURL(ctx, nodeurl)
require.NoError(t, err) require.NoError(t, err)
defer ctx.Check(conn.Close) defer ctx.Check(conn.Close)
client := pb.NewDRPCPiecestoreClient(conn) client := pb.NewDRPCPiecestoreClient(conn)
@ -493,11 +493,11 @@ func TestTooManyRequests(t *testing.T) {
for i, uplink := range planet.Uplinks { for i, uplink := range planet.Uplinks {
i, uplink := i, uplink i, uplink := i, uplink
uploads.Go(func() (err error) { uploads.Go(func() (err error) {
storageNode := planet.StorageNodes[0].Local() storageNode := planet.StorageNodes[0]
config := piecestore.DefaultConfig config := piecestore.DefaultConfig
config.UploadBufferSize = 0 // disable buffering so we can detect write error early config.UploadBufferSize = 0 // disable buffering so we can detect write error early
client, err := piecestore.Dial(ctx, uplink.Dialer, &storageNode.Node, uplink.Log, config) client, err := piecestore.DialNodeURL(ctx, uplink.Dialer, storageNode.NodeURL(), uplink.Log, config)
if err != nil { if err != nil {
return err return err
} }

View File

@ -107,7 +107,10 @@ func (localTime *LocalTime) getSatelliteTime(ctx context.Context, satelliteID st
if err != nil { if err != nil {
return nil, err return nil, err
} }
conn, err := localTime.dialer.DialAddressID(ctx, address, satelliteID) conn, err := localTime.dialer.DialNodeURL(ctx, storj.NodeURL{
ID: satelliteID,
Address: address,
})
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -48,7 +48,7 @@ func Dialer(dialer rpc.Dialer) IdentityResolver {
return IdentityResolverFunc(func(ctx context.Context, url storj.NodeURL) (_ *identity.PeerIdentity, err error) { return IdentityResolverFunc(func(ctx context.Context, url storj.NodeURL) (_ *identity.PeerIdentity, err error) {
defer mon.Task()(&ctx)(&err) defer mon.Task()(&ctx)(&err)
conn, err := dialer.DialAddressID(ctx, url.Address, url.ID) conn, err := dialer.DialNodeURL(ctx, url)
if err != nil { if err != nil {
return nil, err return nil, err
} }