From 135b77dab5ffa4f2fe8cce90092faf6819859db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 27 Jul 2020 13:23:43 +0200 Subject: [PATCH 1/2] Update sector-storage, sealing sched-diag --- api/api_storage.go | 3 +++ api/apistruct/struct.go | 6 ++++++ cmd/lotus-storage-miner/sealing.go | 30 ++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- node/impl/storminer.go | 4 ++++ 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/api/api_storage.go b/api/api_storage.go index 7e6d81b21..3853a8e0f 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -63,6 +63,9 @@ type StorageMiner interface { WorkerStats(context.Context) (map[uint64]storiface.WorkerStats, error) WorkerJobs(context.Context) (map[uint64][]storiface.WorkerJob, error) + // SealingSchedDiag dumps internal sealing scheduler state + SealingSchedDiag(context.Context) (interface{}, error) + stores.SectorIndex MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 6b41fa9dd..a7a392610 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -231,6 +231,8 @@ type StorageMinerStruct struct { WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, error) `perm:"admin"` WorkerJobs func(context.Context) (map[uint64][]storiface.WorkerJob, error) `perm:"admin"` + SealingSchedDiag func(context.Context) (interface{}, error) `perm:"admin"` + StorageList func(context.Context) (map[stores.ID][]stores.Decl, error) `perm:"admin"` StorageLocal func(context.Context) (map[stores.ID]string, error) `perm:"admin"` StorageStat func(context.Context, stores.ID) (fsutil.FsStat, error) `perm:"admin"` @@ -902,6 +904,10 @@ func (c *StorageMinerStruct) WorkerJobs(ctx context.Context) (map[uint64][]stori return c.Internal.WorkerJobs(ctx) } +func (c *StorageMinerStruct) SealingSchedDiag(ctx context.Context) (interface{}, error) { + return c.Internal.SealingSchedDiag(ctx) +} + func (c *StorageMinerStruct) StorageAttach(ctx context.Context, si stores.StorageInfo, st fsutil.FsStat) error { return c.Internal.StorageAttach(ctx, si, st) } diff --git a/cmd/lotus-storage-miner/sealing.go b/cmd/lotus-storage-miner/sealing.go index 68b0a246f..25a1ae890 100644 --- a/cmd/lotus-storage-miner/sealing.go +++ b/cmd/lotus-storage-miner/sealing.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "fmt" "golang.org/x/xerrors" "os" @@ -24,6 +25,7 @@ var sealingCmd = &cli.Command{ Subcommands: []*cli.Command{ sealingJobsCmd, sealingWorkersCmd, + sealingSchedDiagCmd, }, } @@ -176,3 +178,31 @@ var sealingJobsCmd = &cli.Command{ return tw.Flush() }, } + +var sealingSchedDiagCmd = &cli.Command{ + Name: "sched-diag", + Usage: "Dump internal scheduler state", + Action: func(cctx *cli.Context) error { + nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx) + if err != nil { + return err + } + defer closer() + + ctx := lcli.ReqContext(cctx) + + st, err := nodeApi.SealingSchedDiag(ctx) + if err != nil { + return err + } + + j, err := json.MarshalIndent(&st, "", " ") + if err != nil { + return err + } + + fmt.Println(string(j)) + + return nil + }, +} diff --git a/go.mod b/go.mod index 187c6d6b4..c1a65f9c9 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261 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-20200724175351-295300ff4671 + github.com/filecoin-project/sector-storage v0.0.0-20200727112136-9377cb376d25 github.com/filecoin-project/specs-actors v0.8.1-0.20200724015154-3c690d9b7e1d github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea github.com/filecoin-project/storage-fsm v0.0.0-20200720190000-2cfe2fe3c334 diff --git a/go.sum b/go.sum index c065177ef..4bd8bb88b 100644 --- a/go.sum +++ b/go.sum @@ -264,8 +264,8 @@ github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/ github.com/filecoin-project/sector-storage v0.0.0-20200615154852-728a47ab99d6/go.mod h1:M59QnAeA/oV+Z8oHFLoNpGMv0LZ8Rll+vHVXX7GirPM= github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15 h1:miw6hiusb/MkV1ryoqUKKWnvHhPW00AYtyeCj0L8pqo= github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo= -github.com/filecoin-project/sector-storage v0.0.0-20200724175351-295300ff4671 h1:9TqtFwy+6/Ywh3j81vFy3jQerD5DkxFY2Ul8nJPUHwg= -github.com/filecoin-project/sector-storage v0.0.0-20200724175351-295300ff4671/go.mod h1:f9W29dKqNFm8Su4OddGwkAQOYMKYUR5Fk2oC/JZDjCI= +github.com/filecoin-project/sector-storage v0.0.0-20200727112136-9377cb376d25 h1:sTonFkDw3KrIFIJTfIevYXyk+Mu9LbjbOHn/fWoMOMc= +github.com/filecoin-project/sector-storage v0.0.0-20200727112136-9377cb376d25/go.mod h1:f9W29dKqNFm8Su4OddGwkAQOYMKYUR5Fk2oC/JZDjCI= github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= github.com/filecoin-project/specs-actors v0.6.0/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY= diff --git a/node/impl/storminer.go b/node/impl/storminer.go index a5a405735..40b1d8d8c 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -229,6 +229,10 @@ func (sm *StorageMinerAPI) WorkerConnect(ctx context.Context, url string) error return sm.StorageMgr.AddWorker(ctx, w) } +func (sm *StorageMinerAPI) SealingSchedDiag(ctx context.Context) (interface{}, error) { + return sm.StorageMgr.SchedDiag(ctx) +} + func (sm *StorageMinerAPI) MarketImportDealData(ctx context.Context, propCid cid.Cid, path string) error { fi, err := os.Open(path) if err != nil { From 786fe647231274b080bf740a1d98435237a3455a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 27 Jul 2020 13:23:55 +0200 Subject: [PATCH 2/2] gofmt --- api/test/window_post.go | 2 +- node/node_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/api/test/window_post.go b/api/test/window_post.go index 074ba2fbb..b03fe36cc 100644 --- a/api/test/window_post.go +++ b/api/test/window_post.go @@ -233,7 +233,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector require.Equal(t, p.MinerPower, p.TotalPower) sectors := p.MinerPower.RawBytePower.Uint64() / uint64(ssz) - require.Equal(t, nSectors+GenesisPreseals - 3, int(sectors)) // -3 just removed sectors + require.Equal(t, nSectors+GenesisPreseals-3, int(sectors)) // -3 just removed sectors mine = false <-done diff --git a/node/node_test.go b/node/node_test.go index fcef0c444..6e2437437 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -380,7 +380,6 @@ func mockSbBuilder(t *testing.T, nFull int, storage []test.StorageMiner) ([]test } } - for i, def := range storage { // TODO: support non-bootstrap miners