From 9f2df68906eafd20a823cf615f6d415d18a206af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 1 May 2020 20:15:06 +0200 Subject: [PATCH] workers: handle disconnecting workers more gracefully --- api/api_worker.go | 2 ++ api/apistruct/struct.go | 6 ++++++ go.mod | 2 +- go.sum | 4 ++-- lib/jsonrpc/rpc_test.go | 1 - 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/api/api_worker.go b/api/api_worker.go index fa54cb5e8..dbad20651 100644 --- a/api/api_worker.go +++ b/api/api_worker.go @@ -22,4 +22,6 @@ type WorkerApi interface { storage.Sealer Fetch(context.Context, abi.SectorID, stores.SectorFileType, bool) error + + Closing(context.Context) (<-chan struct{}, error) } diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 4855a36bf..8b68e9c79 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -227,6 +227,8 @@ type WorkerStruct struct { FinalizeSector func(context.Context, abi.SectorID) error `perm:"admin"` Fetch func(context.Context, abi.SectorID, stores.SectorFileType, bool) error `perm:"admin"` + + Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"` } } @@ -816,6 +818,10 @@ func (w *WorkerStruct) Fetch(ctx context.Context, id abi.SectorID, fileType stor return w.Internal.Fetch(ctx, id, fileType, b) } +func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) { + return w.Internal.Closing(ctx) +} + var _ api.Common = &CommonStruct{} var _ api.FullNode = &FullNodeStruct{} var _ api.StorageMiner = &StorageMinerStruct{} diff --git a/go.mod b/go.mod index e855882a4..26a4198d6 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/filecoin-project/go-paramfetch v0.0.2-0.20200218225740-47c639bab663 github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b - github.com/filecoin-project/sector-storage v0.0.0-20200429155855-7f1c9c89e735 + github.com/filecoin-project/sector-storage v0.0.0-20200501181153-e4a9a16161e9 github.com/filecoin-project/specs-actors v0.3.0 github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102 github.com/filecoin-project/storage-fsm v0.0.0-20200427182014-01487d5ad3c8 diff --git a/go.sum b/go.sum index aeb734355..928cb2b9b 100644 --- a/go.sum +++ b/go.sum @@ -177,8 +177,8 @@ github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8= github.com/filecoin-project/lotus v0.2.10/go.mod h1:om5PQA9ZT0lf16qI7Fz/ZGLn4LDCMqPC8ntZA9uncRE= github.com/filecoin-project/sector-storage v0.0.0-20200411000242-61616264b16d/go.mod h1:/yueJueMh0Yc+0G1adS0lhnedcSnjY86EjKsA20+DVY= -github.com/filecoin-project/sector-storage v0.0.0-20200429155855-7f1c9c89e735 h1:dzhoQvScipNNexk7Jcgspgf+QLun+gT7FYBdDMMnqgE= -github.com/filecoin-project/sector-storage v0.0.0-20200429155855-7f1c9c89e735/go.mod h1:q/V90xaSKTlu7KovS0uj+cAvlPPFrGn141ZO3iQNEdw= +github.com/filecoin-project/sector-storage v0.0.0-20200501181153-e4a9a16161e9 h1:WG6rFyhbhwWNpB0IExJJpXA8ok4Dduwws/Qy9FYTYfc= +github.com/filecoin-project/sector-storage v0.0.0-20200501181153-e4a9a16161e9/go.mod h1:hvyaNnvsjZ4D/5tq78GWZJ39uTStLJcHRp7cWPeVBgY= github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504/go.mod h1:mdJraXq5vMy0+/FqVQIrnNlpQ/Em6zeu06G/ltQ0/lA= github.com/filecoin-project/specs-actors v0.2.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= diff --git a/lib/jsonrpc/rpc_test.go b/lib/jsonrpc/rpc_test.go index 16edaf9ca..241228e7c 100644 --- a/lib/jsonrpc/rpc_test.go +++ b/lib/jsonrpc/rpc_test.go @@ -378,7 +378,6 @@ func TestChan(t *testing.T) { require.Equal(t, false, ok) } - func TestChanServerClose(t *testing.T) { var client struct { Sub func(context.Context, int, int) (<-chan int, error)