feat: wdpost: Envvar for limiting recovering sectors

This commit is contained in:
Łukasz Magiera 2022-08-01 16:58:05 +02:00 committed by Jennifer Wang
parent fd1207c5c7
commit 3feb9167cb

View File

@ -2,6 +2,8 @@ package wdpost
import (
"context"
"os"
"strconv"
"github.com/ipfs/go-cid"
"go.opencensus.io/trace"
@ -19,6 +21,18 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)
var recoveringSectorLimit int64 = 0
func init() {
if rcl := os.Getenv("LOTUS_RECOVERING_SECTOR_LIMIT"); rcl != "" {
var err error
recoveringSectorLimit, err = strconv.ParseInt(rcl, 10, 64)
if err != nil {
log.Errorw("parsing LOTUS_RECOVERING_SECTOR_LIMIT", "error", err)
}
}
}
// declareRecoveries identifies sectors that were previously marked as faulty
// for our miner, but are now recovered (i.e. are now provable again) and
// still not reported as such.
@ -90,6 +104,11 @@ func (s *WindowPoStScheduler) declareRecoveries(ctx context.Context, dlIdx uint6
Sectors: recovered,
})
if recoveringSectorLimit > 0 && int64(totalRecoveries) >= recoveringSectorLimit {
log.Errorw("reached recovering sector limit, not all sectors will be marked as recovered")
break
}
totalRecoveries++
}