From ecf53f88ce1786fcb02414e6a1a2ef34647c9f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 25 Mar 2020 00:37:40 +0100 Subject: [PATCH] workers: More review related fixes --- cmd/lotus-seal-worker/rpc.go | 2 +- storage/sectorstorage/resources.go | 2 +- storage/sectorstorage/roprov.go | 2 +- storage/sectorstorage/sectorutil/utils.go | 2 +- storage/sectorstorage/stores/http_handler.go | 3 +++ storage/sectorstorage/stores/remote.go | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/lotus-seal-worker/rpc.go b/cmd/lotus-seal-worker/rpc.go index 5d8ce3cb7..254cd47f7 100644 --- a/cmd/lotus-seal-worker/rpc.go +++ b/cmd/lotus-seal-worker/rpc.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/lotus/storage/sectorstorage" ) -type worker struct { // TODO: use advmgr.LocalWorker here +type worker struct { *sectorstorage.LocalWorker } diff --git a/storage/sectorstorage/resources.go b/storage/sectorstorage/resources.go index 3587b41ea..ebb32f165 100644 --- a/storage/sectorstorage/resources.go +++ b/storage/sectorstorage/resources.go @@ -20,7 +20,7 @@ var FsOverheadFinalized = map[sectorbuilder.SectorFileType]int{ type Resources struct { MinMemory uint64 // What Must be in RAM for decent perf - MaxMemory uint64 // Mamory required (swap + ram) + MaxMemory uint64 // Memory required (swap + ram) MultiThread bool CanGPU bool diff --git a/storage/sectorstorage/roprov.go b/storage/sectorstorage/roprov.go index 99723e181..4b0dfbe2b 100644 --- a/storage/sectorstorage/roprov.go +++ b/storage/sectorstorage/roprov.go @@ -15,7 +15,7 @@ type readonlyProvider struct { } func (l *readonlyProvider) AcquireSector(ctx context.Context, id abi.SectorID, existing sectorbuilder.SectorFileType, allocate sectorbuilder.SectorFileType, sealing bool) (sectorbuilder.SectorPaths, func(), error) { - if allocate != 0 { + if allocate != 0 { // 0 - don't allocate anything return sectorbuilder.SectorPaths{}, nil, xerrors.New("read-only storage") } diff --git a/storage/sectorstorage/sectorutil/utils.go b/storage/sectorstorage/sectorutil/utils.go index 01862b7b4..ede59410b 100644 --- a/storage/sectorstorage/sectorutil/utils.go +++ b/storage/sectorstorage/sectorutil/utils.go @@ -14,7 +14,7 @@ func ParseSectorID(baseName string) (abi.SectorID, error) { var mid abi.ActorID read, err := fmt.Sscanf(baseName, "s-t0%d-%d", &mid, &n) if err != nil { - return abi.SectorID{}, xerrors.Errorf(": %w", err) + return abi.SectorID{}, xerrors.Errorf("sscanf sector name ('%s'): %w", baseName, err) } if read != 2 { diff --git a/storage/sectorstorage/stores/http_handler.go b/storage/sectorstorage/stores/http_handler.go index 657da0f9b..b242d1159 100644 --- a/storage/sectorstorage/stores/http_handler.go +++ b/storage/sectorstorage/stores/http_handler.go @@ -68,11 +68,13 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ ft, err := ftFromString(vars["type"]) if err != nil { log.Error("%+v", err) + w.WriteHeader(500) return } paths, _, done, err := handler.Local.AcquireSector(r.Context(), id, ft, 0, false) if err != nil { log.Error("%+v", err) + w.WriteHeader(500) return } defer done() @@ -126,6 +128,7 @@ func (handler *FetchHandler) remoteDeleteSector(w http.ResponseWriter, r *http.R ft, err := ftFromString(vars["type"]) if err != nil { log.Error("%+v", err) + w.WriteHeader(500) return } diff --git a/storage/sectorstorage/stores/remote.go b/storage/sectorstorage/stores/remote.go index ab7d465b3..66b818434 100644 --- a/storage/sectorstorage/stores/remote.go +++ b/storage/sectorstorage/stores/remote.go @@ -273,7 +273,7 @@ func (r *Remote) FsStat(ctx context.Context, id ID) (FsStat, error) { return FsStat{}, xerrors.Errorf("fsstat: got http 500, then failed to read the error: %w", err) } - return FsStat{}, xerrors.New(string(b)) + return FsStat{}, xerrors.Errorf("fsstat: got http 500: %s", string(b)) } var out FsStat