satellite/{overlay,satellitedb}: remove unused methods for old downtime tracking
GetSuccessfulNodeNotCheckedInSince and GetOfflineNodesLimited are overlay methods which were only used by the previous downtime tracking system which has been removed. These methods should also be removed. Change-Id: Idb829d742e1f987e095604423fff656fe581183e
This commit is contained in:
parent
cf56071bb4
commit
0403e99a5b
@ -86,11 +86,6 @@ type DB interface {
|
||||
// GetNodesNetwork returns the /24 subnet for each storage node, order is not guaranteed.
|
||||
GetNodesNetwork(ctx context.Context, nodeIDs []storj.NodeID) (nodeNets []string, err error)
|
||||
|
||||
// GetSuccesfulNodesNotCheckedInSince returns all nodes that last check-in was successful, but haven't checked-in within a given duration.
|
||||
GetSuccesfulNodesNotCheckedInSince(ctx context.Context, duration time.Duration) (nodeAddresses []NodeLastContact, err error)
|
||||
// GetOfflineNodesLimited returns a list of the first N offline nodes ordered by least recently contacted.
|
||||
GetOfflineNodesLimited(ctx context.Context, limit int) ([]NodeLastContact, error)
|
||||
|
||||
// DisqualifyNode disqualifies a storage node.
|
||||
DisqualifyNode(ctx context.Context, nodeID storj.NodeID) (err error)
|
||||
|
||||
@ -490,13 +485,6 @@ func (service *Service) UpdateCheckIn(ctx context.Context, node NodeCheckInInfo,
|
||||
return service.db.UpdateCheckIn(ctx, node, timestamp, service.config.Node)
|
||||
}
|
||||
|
||||
// GetSuccesfulNodesNotCheckedInSince returns all nodes that last check-in was successful, but haven't checked-in within a given duration.
|
||||
func (service *Service) GetSuccesfulNodesNotCheckedInSince(ctx context.Context, duration time.Duration) (nodeLastContacts []NodeLastContact, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
return service.db.GetSuccesfulNodesNotCheckedInSince(ctx, duration)
|
||||
}
|
||||
|
||||
// GetMissingPieces returns the list of offline nodes.
|
||||
func (service *Service) GetMissingPieces(ctx context.Context, pieces []*pb.RemotePiece) (missingPieces []int32, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
@ -525,12 +513,6 @@ func (service *Service) DisqualifyNode(ctx context.Context, nodeID storj.NodeID)
|
||||
return service.db.DisqualifyNode(ctx, nodeID)
|
||||
}
|
||||
|
||||
// GetOfflineNodesLimited returns a list of the first N offline nodes ordered by least recently contacted.
|
||||
func (service *Service) GetOfflineNodesLimited(ctx context.Context, limit int) (offlineNodes []NodeLastContact, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
return service.db.GetOfflineNodesLimited(ctx, limit)
|
||||
}
|
||||
|
||||
// ResolveIPAndNetwork resolves the target address and determines its IP and /24 subnet IPv4 or /64 subnet IPv6.
|
||||
func ResolveIPAndNetwork(ctx context.Context, target string) (ipPort, network string, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
@ -645,101 +645,6 @@ func TestUpdateCheckIn(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCache_DowntimeTracking(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
cache := db.OverlayCache()
|
||||
defaults := overlay.NodeSelectionConfig{}
|
||||
|
||||
totalNodes := 10
|
||||
allIDs := make(storj.NodeIDList, totalNodes)
|
||||
// put nodes in cache
|
||||
for i := 0; i < totalNodes; i++ {
|
||||
newID := testrand.NodeID()
|
||||
addr := fmt.Sprintf("127.0.%d.0:8080", 0)
|
||||
lastNet := fmt.Sprintf("127.0.%d", 0)
|
||||
d := overlay.NodeCheckInInfo{
|
||||
NodeID: newID,
|
||||
Address: &pb.NodeAddress{Address: addr, Transport: pb.NodeTransport_TCP_TLS_GRPC},
|
||||
LastIPPort: addr,
|
||||
LastNet: lastNet,
|
||||
Version: &pb.NodeVersion{Version: "v1.0.0"},
|
||||
Capacity: &pb.NodeCapacity{},
|
||||
IsUp: true,
|
||||
}
|
||||
err := cache.UpdateCheckIn(ctx, d, time.Now().UTC(), defaults)
|
||||
require.NoError(t, err)
|
||||
|
||||
allIDs[i] = newID
|
||||
|
||||
// make half of the nodes (0, 2, 4, 6, 8) offline + not disqualified
|
||||
if i%2 == 0 {
|
||||
_, err := cache.UpdateUptime(ctx, newID, false)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
// make first node (0) offline + disqualified
|
||||
if i == 0 {
|
||||
_, err := cache.UpdateUptime(ctx, newID, false)
|
||||
require.NoError(t, err)
|
||||
err = cache.DisqualifyNode(ctx, newID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
nodes, err := cache.GetOfflineNodesLimited(ctx, 10)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, nodes, 4)
|
||||
// order of nodes should be least recently checked first
|
||||
require.Equal(t, allIDs[2], nodes[0].URL.ID)
|
||||
require.Equal(t, allIDs[4], nodes[1].URL.ID)
|
||||
require.Equal(t, allIDs[6], nodes[2].URL.ID)
|
||||
require.Equal(t, allIDs[8], nodes[3].URL.ID)
|
||||
|
||||
// test with limit
|
||||
nodes, err = cache.GetOfflineNodesLimited(ctx, 2)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, nodes, 2)
|
||||
// order of nodes should be least recently checked first
|
||||
require.Equal(t, allIDs[2], nodes[0].URL.ID)
|
||||
require.Equal(t, allIDs[4], nodes[1].URL.ID)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetSuccesfulNodesNotCheckedInSince(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // setup
|
||||
info1 := getNodeInfo(testrand.NodeID())
|
||||
info2 := getNodeInfo(testrand.NodeID())
|
||||
|
||||
{ // check-in the nodes, which should add them
|
||||
twoHoursAgo := time.Now().Add(-2 * time.Hour)
|
||||
err := db.OverlayCache().UpdateCheckIn(ctx, info1, twoHoursAgo, overlay.NodeSelectionConfig{})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = db.OverlayCache().UpdateCheckIn(ctx, info2, twoHoursAgo, overlay.NodeSelectionConfig{})
|
||||
require.NoError(t, err)
|
||||
|
||||
// update uptime so that node 2 has a last contact failure > last contact success
|
||||
_, err = db.OverlayCache().UpdateUptime(ctx, info2.NodeID, false)
|
||||
require.NoError(t, err)
|
||||
|
||||
// should just get 1 node
|
||||
nodeLastContacts, err := db.OverlayCache().GetSuccesfulNodesNotCheckedInSince(ctx, time.Duration(0))
|
||||
require.NoError(t, err)
|
||||
require.Len(t, nodeLastContacts, 1)
|
||||
require.WithinDuration(t, twoHoursAgo, nodeLastContacts[0].LastContactSuccess, time.Second)
|
||||
require.True(t, nodeLastContacts[0].LastContactFailure.IsZero())
|
||||
}
|
||||
|
||||
{ // check-in again with current time
|
||||
err := db.OverlayCache().UpdateCheckIn(ctx, info1, time.Now(), overlay.NodeSelectionConfig{})
|
||||
require.NoError(t, err)
|
||||
|
||||
nodeLastContacts, err := db.OverlayCache().GetSuccesfulNodesNotCheckedInSince(ctx, time.Minute)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, nodeLastContacts, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TestSuspendedSelection ensures that suspended nodes are not selected by SelectStorageNodes.
|
||||
func TestSuspendedSelection(t *testing.T) {
|
||||
totalNodes := 10
|
||||
|
@ -1003,38 +1003,6 @@ func (cache *overlaycache) UpdateExitStatus(ctx context.Context, request *overla
|
||||
return convertDBNode(ctx, dbNode)
|
||||
}
|
||||
|
||||
// GetSuccesfulNodesNotCheckedInSince returns all nodes that last check-in was successful, but haven't checked-in within a given duration.
|
||||
func (cache *overlaycache) GetSuccesfulNodesNotCheckedInSince(ctx context.Context, duration time.Duration) (nodeLastContacts []overlay.NodeLastContact, err error) {
|
||||
// get successful nodes that have not checked-in with the hour
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
dbxNodes, err := cache.db.DB.All_Node_Id_Node_Address_Node_LastIpPort_Node_LastContactSuccess_Node_LastContactFailure_By_LastContactSuccess_Less_And_LastContactSuccess_Greater_LastContactFailure_And_Disqualified_Is_Null_OrderBy_Asc_LastContactSuccess(
|
||||
ctx, dbx.Node_LastContactSuccess(time.Now().UTC().Add(-duration)))
|
||||
if err != nil {
|
||||
return nil, Error.Wrap(err)
|
||||
}
|
||||
|
||||
for _, node := range dbxNodes {
|
||||
nodeID, err := storj.NodeIDFromBytes(node.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodeLastContact := overlay.NodeLastContact{
|
||||
URL: storj.NodeURL{ID: nodeID, Address: node.Address},
|
||||
LastContactSuccess: node.LastContactSuccess.UTC(),
|
||||
LastContactFailure: node.LastContactFailure.UTC(),
|
||||
}
|
||||
if node.LastIpPort != nil {
|
||||
nodeLastContact.LastIPPort = *node.LastIpPort
|
||||
}
|
||||
|
||||
nodeLastContacts = append(nodeLastContacts, nodeLastContact)
|
||||
}
|
||||
|
||||
return nodeLastContacts, nil
|
||||
}
|
||||
|
||||
func populateExitStatusFields(req *overlay.ExitStatusRequest) dbx.Node_Update_Fields {
|
||||
dbxUpdateFields := dbx.Node_Update_Fields{}
|
||||
|
||||
@ -1052,36 +1020,6 @@ func populateExitStatusFields(req *overlay.ExitStatusRequest) dbx.Node_Update_Fi
|
||||
return dbxUpdateFields
|
||||
}
|
||||
|
||||
// GetOfflineNodesLimited returns a list of the first N offline nodes ordered by least recently contacted.
|
||||
func (cache *overlaycache) GetOfflineNodesLimited(ctx context.Context, limit int) (nodeLastContacts []overlay.NodeLastContact, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
dbxNodes, err := cache.db.DB.Limited_Node_Id_Node_Address_Node_LastIpPort_Node_LastContactSuccess_Node_LastContactFailure_By_LastContactSuccess_Less_LastContactFailure_And_Disqualified_Is_Null_OrderBy_Asc_LastContactFailure(
|
||||
ctx, limit, 0)
|
||||
if err != nil {
|
||||
return nil, Error.Wrap(err)
|
||||
}
|
||||
for _, node := range dbxNodes {
|
||||
nodeID, err := storj.NodeIDFromBytes(node.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodeLastContact := overlay.NodeLastContact{
|
||||
URL: storj.NodeURL{ID: nodeID, Address: node.Address},
|
||||
LastContactSuccess: node.LastContactSuccess.UTC(),
|
||||
LastContactFailure: node.LastContactFailure.UTC(),
|
||||
}
|
||||
if node.LastIpPort != nil {
|
||||
nodeLastContact.LastIPPort = *node.LastIpPort
|
||||
}
|
||||
|
||||
nodeLastContacts = append(nodeLastContacts, nodeLastContact)
|
||||
}
|
||||
|
||||
return nodeLastContacts, nil
|
||||
}
|
||||
|
||||
func convertDBNode(ctx context.Context, info *dbx.Node) (_ *overlay.NodeDossier, err error) {
|
||||
if info == nil {
|
||||
return nil, Error.New("missing info")
|
||||
|
Loading…
Reference in New Issue
Block a user