Skip to content

Commit

Permalink
streamline migration progress log timeout handling
Browse files Browse the repository at this point in the history
  • Loading branch information
virajbhartiya committed Dec 11, 2024
1 parent d0df190 commit 2d271c7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
36 changes: 22 additions & 14 deletions chain/consensus/filcns/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2753,14 +2753,10 @@ func PreUpgradeActorsV16(ctx context.Context, sm *stmgr.StateManager, cache stmg
if err != nil {
return xerrors.Errorf("error getting lookback ts for premigration: %w", err)
}
timeout := os.Getenv("LOTUS_MIGRATE_PROGRESS_LOG_SECONDS")
timeoutDuration, err := time.ParseDuration(timeout + "s")
if err != nil {
return xerrors.Errorf("error parsing LOTUS_MIGRATE_PROGRESS_LOG_SECONDS: %w", err)
}

if timeoutDuration == 0 {
timeoutDuration = time.Second * 2
timeoutDuration, err := getMigrationProgressLogTimeout()
if err != nil {
return xerrors.Errorf("error getting progress log timeout: %w", err)
}

config := migration.Config{
Expand All @@ -2779,14 +2775,10 @@ func UpgradeActorsV16(ctx context.Context, sm *stmgr.StateManager, cache stmgr.M
if workerCount <= 0 {
workerCount = 1
}
timeout := os.Getenv("LOTUS_MIGRATE_PROGRESS_LOG_SECONDS")
timeoutDuration, err := time.ParseDuration(timeout + "s")
if err != nil {
return cid.Undef, xerrors.Errorf("error parsing LOTUS_MIGRATE_PROGRESS_LOG_SECONDS: %w", err)
}

if timeoutDuration == 0 {
timeoutDuration = time.Second * 2
timeoutDuration, err := getMigrationProgressLogTimeout()
if err != nil {
return cid.Undef, xerrors.Errorf("error getting progress log timeout: %w", err)
}

config := migration.Config{
Expand Down Expand Up @@ -3024,3 +3016,19 @@ func (ml migrationLogger) Log(level rt.LogLevel, msg string, args ...interface{}
log.Errorf(msg, args...)
}
}

func getMigrationProgressLogTimeout() (time.Duration, error) {
timeoutDuration := time.Second * 2 // default timeout
timeout := os.Getenv("LOTUS_MIGRATE_PROGRESS_LOG_SECONDS")
if timeout != "" {
seconds, err := strconv.Atoi(timeout)
if err != nil {
return 0, xerrors.Errorf("LOTUS_MIGRATE_PROGRESS_LOG_SECONDS must be an integer: %w", err)
}
if seconds <= 0 {
return 0, xerrors.Errorf("LOTUS_MIGRATE_PROGRESS_LOG_SECONDS must be positive")
}
timeoutDuration = time.Duration(seconds) * time.Second
}
return timeoutDuration, nil
}
1 change: 0 additions & 1 deletion extern/go-state-types
Submodule go-state-types deleted from c3f3a3
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ replace github.com/filecoin-project/test-vectors => ./extern/test-vectors // pro

replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi // provided via a git submodule

replace github.com/filecoin-project/go-state-types => ./extern/go-state-types // provided via a git submodule
replace github.com/filecoin-project/go-state-types => github.com/filecoin-project/go-state-types v0.16.0-rc1 // provided via a git submodule

require (
contrib.go.opencensus.io/exporter/prometheus v0.4.2
Expand Down Expand Up @@ -52,7 +52,7 @@ require (
github.com/filecoin-project/go-jsonrpc v0.7.0
github.com/filecoin-project/go-padreader v0.0.1
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.16.0-dev
github.com/filecoin-project/go-state-types v0.16.0-rc1
github.com/filecoin-project/go-statemachine v1.0.3
github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/go-storedcounter v0.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ github.com/filecoin-project/go-padreader v0.0.1 h1:8h2tVy5HpoNbr2gBRr+WD6zV6VD6X
github.com/filecoin-project/go-padreader v0.0.1/go.mod h1:VYVPJqwpsfmtoHnAmPx6MUwmrK6HIcDqZJiuZhtmfLQ=
github.com/filecoin-project/go-paramfetch v0.0.4 h1:H+Me8EL8T5+79z/KHYQQcT8NVOzYVqXIi7nhb48tdm8=
github.com/filecoin-project/go-paramfetch v0.0.4/go.mod h1:1FH85P8U+DUEmWk1Jkw3Bw7FrwTVUNHk/95PSPG+dts=
github.com/filecoin-project/go-state-types v0.16.0-rc1 h1:/51MhupBAjfmWygUKDZCdLOzAnKFcayPHX9ApTswgmo=
github.com/filecoin-project/go-state-types v0.16.0-rc1/go.mod h1:4rjTgHP6LWrkQXQCgx+dRGDa0gnk4WiJVCFwZtuDOGE=
github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk=
github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
Expand Down

0 comments on commit 2d271c7

Please sign in to comment.