Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R4R] Recover from last running mode when restarts #466

Merged
merged 1 commit into from
Apr 11, 2019

Conversation

rickyyangz
Copy link
Contributor

Description

Persistent the running mode to file when update. So we can recover from it when restarts.

Rationale

After setting to recovery mode, we would do some fix and restart the node, the node needs to run still in recovery mode when started.
Before this PR, we use a param in StartCmd to manually specify the mode. It's not friendly to our deployment scripts.

Example

Changes

Notable changes:
*

  • ...

Preflight checks

  • build passed (make build)
  • tests passed (make test)
  • integration tests passed (make integration_test)
  • manual transaction test passed (cli invoke)

Already reviewed by

...

Related issues

... reference related issue #'s here ...

@rickyyangz rickyyangz changed the base branch from master to develop March 4, 2019 11:33
common/runtime/recover.go Outdated Show resolved Hide resolved
@unclezoro
Copy link
Collaborator

related with bnb-chain/bnc-tendermint#34. Please notice merged order

if mode == "0" {
runtime.RunningMode = runtime.NormalMode
runningMode = runtime.NormalMode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What concern to verify a query request?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what did you mean here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my understand, although this is a query request, it can set the node working mode. So the query request should provide the signature on once data to acquire the setting permission.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even it's a query request, we need to check the permission

appConfig "github.com/binance-chain/node/app/config"
"github.com/binance-chain/node/common/log"
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this file less dependency. Like func mustSaveToFile(cfg *config.Config, params *runtimeParams) . to func mustSaveToFile(filePath string, params *runtimeParams) .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@darren-liu darren-liu changed the title [R4R] Recover from last running mode when restarts [WIP] Recover from last running mode when restarts Apr 10, 2019
@rickyyangz rickyyangz changed the title [WIP] Recover from last running mode when restarts [R4R] Recover from last running mode when restarts Apr 11, 2019
admin/handler.go Show resolved Hide resolved
if mode == "0" {
runtime.RunningMode = runtime.NormalMode
runningMode = runtime.NormalMode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what did you mean here?

params = mustReadFromFile(path)
params.Mode = mode
}
mustSaveToFile(path, params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we use mustSaveToFile here? does it mean if we failed to save, the process would crash?

I would rather return the error back to command line, so that the command fails, and the caller of the command should handle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it failed to save to the file, it must be an internal error, we can just panic here and the recover() logic will return an internal error to the client.

@rickyyangz rickyyangz merged commit ee70cd5 into develop Apr 11, 2019
@unclezoro unclezoro deleted the feature/runtime_recover branch May 10, 2022 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants