Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove map pintracker #944

Merged
merged 26 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
51a917c
Remove map pintracker
Oct 23, 2019
6b0b8ff
Remove the Sync operations from everywhere
Oct 24, 2019
fe8c13c
Modify pintracker to use a state.ReadOnly instead of rpc calls
Oct 28, 2019
b6382e0
check if state is nil and tests
Oct 29, 2019
6d70bcd
Use the consensus component directly instead of using state
Oct 30, 2019
1d98bfd
remove mockState
Oct 30, 2019
f92a300
Remove util package, add tests
Nov 3, 2019
68970e6
Use state instead of consensus
Nov 3, 2019
12c4c7f
remove ipfs sync interval, state sync body
Nov 4, 2019
a05039e
Merge branch 'master' into task/remove-mappintracker
Nov 5, 2019
9f41f12
Set state when consesus is ready, use CallContext instead of Call
Nov 5, 2019
000895a
temp
Nov 8, 2019
fe0b01e
Addressed reviews
Nov 11, 2019
53259d0
Remove mockCluster
Nov 11, 2019
0613142
Fix stateless New call in cluster test
Nov 12, 2019
02e9d65
Merge branch 'master' into task/remove-mappintracker
Nov 12, 2019
44cc96f
Remove blocking ready check
Nov 12, 2019
bf758d4
Used dsstate instead of mockstate
Nov 15, 2019
d7985ae
Fixing go: github.com/btcsuite/btcd@v0.20.0-beta: reading https://pro…
Nov 15, 2019
157e994
Removing unwanted changes
Nov 16, 2019
ea595d6
Merge branch 'master' into task/remove-mappintracker
hsanjuan Dec 12, 2019
496ea4a
Maintenance to stateless pintracker
hsanjuan Dec 12, 2019
1a5844b
stateless: Remove cleaner ticker. Do not track Sharded pins.
hsanjuan Dec 12, 2019
d9ed188
pintracker: Give some more time to cancel the operation test
hsanjuan Dec 12, 2019
98a603b
Remove more references to mappintracker
hsanjuan Dec 12, 2019
a39a165
pintracker: golint
hsanjuan Dec 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions api/rest/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ type Client interface {
// StatusAll gathers Status() for all tracked items.
StatusAll(ctx context.Context, filter api.TrackerStatus, local bool) ([]*api.GlobalPinInfo, error)

// Sync makes sure the state of a Cid corresponds to the state reported
// by the ipfs daemon, and returns it. If local is true, this operation
// only happens on the current peer, otherwise it happens on every
// cluster peer.
Sync(ctx context.Context, ci cid.Cid, local bool) (*api.GlobalPinInfo, error)
// SyncAll triggers Sync() operations for all tracked items. It only
// returns informations for items that were de-synced or have an error
// state. If local is true, the operation is limited to the current
// peer. Otherwise it happens on every cluster peer.
SyncAll(ctx context.Context, local bool) ([]*api.GlobalPinInfo, error)

// Recover retriggers pin or unpin ipfs operations for a Cid in error
// state. If local is true, the operation is limited to the current
// peer, otherwise it happens on every cluster peer.
Expand Down
31 changes: 0 additions & 31 deletions api/rest/client/lbclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,37 +268,6 @@ func (lc *loadBalancingClient) StatusAll(ctx context.Context, filter api.Tracker
return pinInfos, err
}

// Sync makes sure the state of a Cid corresponds to the state reported by
// the ipfs daemon, and returns it. If local is true, this operation only
// happens on the current peer, otherwise it happens on every cluster peer.
func (lc *loadBalancingClient) Sync(ctx context.Context, ci cid.Cid, local bool) (*api.GlobalPinInfo, error) {
var pinInfo *api.GlobalPinInfo
call := func(c Client) error {
var err error
pinInfo, err = c.Sync(ctx, ci, local)
return err
}

err := lc.retry(0, call)
return pinInfo, err
}

// SyncAll triggers Sync() operations for all tracked items. It only returns
// informations for items that were de-synced or have an error state. If
// local is true, the operation is limited to the current peer. Otherwise
// it happens on every cluster peer.
func (lc *loadBalancingClient) SyncAll(ctx context.Context, local bool) ([]*api.GlobalPinInfo, error) {
var pinInfos []*api.GlobalPinInfo
call := func(c Client) error {
var err error
pinInfos, err = c.SyncAll(ctx, local)
return err
}

err := lc.retry(0, call)
return pinInfos, err
}

// Recover retriggers pin or unpin ipfs operations for a Cid in error state.
// If local is true, the operation is limited to the current peer, otherwise
// it happens on every cluster peer.
Expand Down
32 changes: 0 additions & 32 deletions api/rest/client/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,38 +250,6 @@ func (c *defaultClient) StatusAll(ctx context.Context, filter api.TrackerStatus,
return gpis, err
}

// Sync makes sure the state of a Cid corresponds to the state reported by
// the ipfs daemon, and returns it. If local is true, this operation only
// happens on the current peer, otherwise it happens on every cluster peer.
func (c *defaultClient) Sync(ctx context.Context, ci cid.Cid, local bool) (*api.GlobalPinInfo, error) {
ctx, span := trace.StartSpan(ctx, "client/Sync")
defer span.End()

var gpi api.GlobalPinInfo
err := c.do(
ctx,
"POST",
fmt.Sprintf("/pins/%s/sync?local=%t", ci.String(), local),
nil,
nil,
&gpi,
)
return &gpi, err
}

// SyncAll triggers Sync() operations for all tracked items. It only returns
// informations for items that were de-synced or have an error state. If
// local is true, the operation is limited to the current peer. Otherwise
// it happens on every cluster peer.
func (c *defaultClient) SyncAll(ctx context.Context, local bool) ([]*api.GlobalPinInfo, error) {
ctx, span := trace.StartSpan(ctx, "client/SyncAll")
defer span.End()

var gpis []*api.GlobalPinInfo
err := c.do(ctx, "POST", fmt.Sprintf("/pins/sync?local=%t", local), nil, nil, &gpis)
return gpis, err
}

// Recover retriggers pin or unpin ipfs operations for a Cid in error state.
// If local is true, the operation is limited to the current peer, otherwise
// it happens on every cluster peer.
Expand Down
37 changes: 0 additions & 37 deletions api/rest/client/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,43 +376,6 @@ func TestStatusAll(t *testing.T) {
testClients(t, api, testF)
}

func TestSync(t *testing.T) {
ctx := context.Background()
api := testAPI(t)
defer shutdown(api)

testF := func(t *testing.T, c Client) {
pin, err := c.Sync(ctx, test.Cid1, false)
if err != nil {
t.Fatal(err)
}
if !pin.Cid.Equals(test.Cid1) {
t.Error("should be same pin")
}
}

testClients(t, api, testF)
}

func TestSyncAll(t *testing.T) {
ctx := context.Background()
api := testAPI(t)
defer shutdown(api)

testF := func(t *testing.T, c Client) {
pins, err := c.SyncAll(ctx, false)
if err != nil {
t.Fatal(err)
}

if len(pins) == 0 {
t.Error("there should be some pins")
}
}

testClients(t, api, testF)
}

func TestRecover(t *testing.T) {
ctx := context.Background()
api := testAPI(t)
Expand Down
72 changes: 0 additions & 72 deletions api/rest/restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,18 +409,6 @@ func (api *API) routes() []route {
"/pins",
api.statusAllHandler,
},
{
"Sync",
"POST",
"/pins/{hash}/sync",
api.syncHandler,
},
{
"SyncAll",
"POST",
"/pins/sync",
api.syncAllHandler,
},
{
"Recover",
"POST",
Expand Down Expand Up @@ -978,66 +966,6 @@ func (api *API) statusHandler(w http.ResponseWriter, r *http.Request) {
}
}

func (api *API) syncAllHandler(w http.ResponseWriter, r *http.Request) {
queryValues := r.URL.Query()
local := queryValues.Get("local")

if local == "true" {
var pinInfos []*types.PinInfo
err := api.rpcClient.CallContext(
r.Context(),
"",
"Cluster",
"SyncAllLocal",
struct{}{},
&pinInfos,
)
api.sendResponse(w, autoStatus, err, pinInfosToGlobal(pinInfos))
} else {
var pinInfos []*types.GlobalPinInfo
err := api.rpcClient.CallContext(
r.Context(),
"",
"Cluster",
"SyncAll",
struct{}{},
&pinInfos,
)
api.sendResponse(w, autoStatus, err, pinInfos)
}
}

func (api *API) syncHandler(w http.ResponseWriter, r *http.Request) {
queryValues := r.URL.Query()
local := queryValues.Get("local")

if pin := api.parseCidOrError(w, r); pin != nil {
if local == "true" {
var pinInfo types.PinInfo
err := api.rpcClient.CallContext(
r.Context(),
"",
"Cluster",
"SyncLocal",
pin.Cid,
&pinInfo,
)
api.sendResponse(w, autoStatus, err, pinInfoToGlobal(&pinInfo))
} else {
var pinInfo types.GlobalPinInfo
err := api.rpcClient.CallContext(
r.Context(),
"",
"Cluster",
"Sync",
pin.Cid,
&pinInfo,
)
api.sendResponse(w, autoStatus, err, pinInfo)
}
}
}

func (api *API) recoverAllHandler(w http.ResponseWriter, r *http.Request) {
queryValues := r.URL.Query()
local := queryValues.Get("local")
Expand Down
66 changes: 0 additions & 66 deletions api/rest/restapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,72 +951,6 @@ func TestAPIStatusEndpoint(t *testing.T) {
testBothEndpoints(t, tf)
}

func TestAPISyncAllEndpoint(t *testing.T) {
ctx := context.Background()
rest := testAPI(t)
defer rest.Shutdown(ctx)

tf := func(t *testing.T, url urlF) {
var resp []*api.GlobalPinInfo
makePost(t, rest, url(rest)+"/pins/sync", []byte{}, &resp)

if len(resp) != 3 ||
!resp[0].Cid.Equals(test.Cid1) ||
resp[1].PeerMap[peer.IDB58Encode(test.PeerID1)].Status.String() != "pinning" {
t.Errorf("unexpected syncAll resp:\n %+v", resp)
}

// Test local=true
var resp2 []*api.GlobalPinInfo
makePost(t, rest, url(rest)+"/pins/sync?local=true", []byte{}, &resp2)

if len(resp2) != 2 {
t.Errorf("unexpected syncAll+local resp:\n %+v", resp2)
}
}

testBothEndpoints(t, tf)
}

func TestAPISyncEndpoint(t *testing.T) {
ctx := context.Background()
rest := testAPI(t)
defer rest.Shutdown(ctx)

tf := func(t *testing.T, url urlF) {
var resp api.GlobalPinInfo
makePost(t, rest, url(rest)+"/pins/"+test.Cid1.String()+"/sync", []byte{}, &resp)

if !resp.Cid.Equals(test.Cid1) {
t.Error("expected the same cid")
}
info, ok := resp.PeerMap[peer.IDB58Encode(test.PeerID1)]
if !ok {
t.Fatal("expected info for test.PeerID1")
}
if info.Status.String() != "pinned" {
t.Error("expected different status")
}

// Test local=true
var resp2 api.GlobalPinInfo
makePost(t, rest, url(rest)+"/pins/"+test.Cid1.String()+"/sync?local=true", []byte{}, &resp2)

if !resp2.Cid.Equals(test.Cid1) {
t.Error("expected the same cid")
}
info, ok = resp2.PeerMap[peer.IDB58Encode(test.PeerID2)]
if !ok {
t.Fatal("expected info for test.PeerID2")
}
if info.Status.String() != "pinned" {
t.Error("expected different status")
}
}

testBothEndpoints(t, tf)
}

func TestAPIRecoverEndpoint(t *testing.T) {
ctx := context.Background()
rest := testAPI(t)
Expand Down