flow-go icon indicating copy to clipboard operation
flow-go copied to clipboard

Admin command for dynamic config updates

Open jordanschalm opened this issue 2 years ago • 1 comments

This PR adds the ConfigManager and associated admin commands, which simplifies making dynamically updatable configs, and adds block-rate-delay as a dynamically updatable config.

  • Adds admin commands
    • list-configs - lists all available configs which may be dynamically updated via admin command
    • get-config $CONFIG_NAME - returns the current value of a dynamically updatable config
    • set-config {$CONFIG_NAME: $NEW_VALUE} - sets the value of the given config, returns the old and new config value
  • Replaces existing admin commands which modify a config, to use the ConfigManager instead
    • set-profiler-enabled
    • set-required-approvals-for-sealing

Example Usage

# Set block rate delay to 10s (from initial value of 800ms)
dapperlabs@J-Mac-DL localnet % curl localhost:3705/admin/run_command -H 'Content-Type: application/json' -d '{"commandName": "set-config", "data": {"hotstuff-block-rate-delay": "10s"}}'
{"output":{"newValue":"10s", "oldValue":"800ms"}}%
dapperlabs@J-Mac-DL localnet % curl localhost:3706/admin/run_command -H 'Content-Type: application/json' -d '{"commandName": "set-config", "data": {"hotstuff-block-rate-delay": "10s"}}'
{"output":{"newValue":"10s", "oldValue":"800ms"}}%
dapperlabs@J-Mac-DL localnet % curl localhost:3707/admin/run_command -H 'Content-Type: application/json' -d '{"commandName": "set-config", "data": {"hotstuff-block-rate-delay": "10s"}}'
{"output":{"newValue":"10s", "oldValue":"800ms"}}%

# Then, set block rate delay to 10ms
dapperlabs@J-Mac-DL localnet % curl localhost:3707/admin/run_command -H 'Content-Type: application/json' -d '{"commandName": "set-config", "data": {"hotstuff-block-rate-delay": "10ms"}}'
{"output":{"newValue":"10ms", "oldValue":"10s"}}%
dapperlabs@J-Mac-DL localnet % curl localhost:3706/admin/run_command -H 'Content-Type: application/json' -d '{"commandName": "set-config", "data": {"hotstuff-block-rate-delay": "10ms"}}'
{"output":{"newValue":"10ms", "oldValue":"10s"}}%
dapperlabs@J-Mac-DL localnet % curl localhost:3705/admin/run_command -H 'Content-Type: application/json' -d '{"commandName": "set-config", "data": {"hotstuff-block-rate-delay": "10ms"}}'
{"output":{"newValue":"10ms", "oldValue":"10s"}}%
image

jordanschalm avatar Oct 12 '22 08:10 jordanschalm

Codecov Report

Merging #3369 (c5646e2) into master (aa3a53c) will decrease coverage by 0.01%. The diff coverage is 36.99%.

@@            Coverage Diff             @@
##           master    #3369      +/-   ##
==========================================
- Coverage   55.63%   55.61%   -0.02%     
==========================================
  Files         759      761       +2     
  Lines       70040    70211     +171     
==========================================
+ Hits        38965    39048      +83     
- Misses      27884    27970      +86     
- Partials     3191     3193       +2     
Flag Coverage Δ
unittests 55.61% <36.99%> (-0.02%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
admin/command_runner.go 82.12% <ø> (ø)
admin/commands/common/get_config.go 0.00% <0.00%> (ø)
admin/commands/common/list_configs.go 0.00% <0.00%> (ø)
admin/commands/common/set_config.go 0.00% <0.00%> (ø)
cmd/node_builder.go 93.87% <ø> (ø)
cmd/scaffold.go 17.83% <0.00%> (-0.23%) :arrow_down:
consensus/config.go 0.00% <0.00%> (ø)
consensus/participant.go 17.10% <0.00%> (+0.22%) :arrow_up:
utils/unittest/fixtures.go 0.00% <0.00%> (ø)
consensus/hotstuff/pacemaker/timeout/config.go 81.81% <42.10%> (-13.27%) :arrow_down:
... and 13 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Oct 13 '22 14:10 codecov-commenter

bors merge

jordanschalm avatar Nov 01 '22 16:11 jordanschalm