diff options
author | Mike Wallace <mikewallace1979@googlemail.com> | 2014-08-19 18:30:26 +0100 |
---|---|---|
committer | Jay Doane <jaydoane@apache.org> | 2021-04-19 00:34:24 -0700 |
commit | 67fd6f3a6e2d4b55b547de7e0fc822939fb0d48f (patch) | |
tree | 658fa8f6a948bc565a440793ed558839c62a26d6 | |
parent | 372e6a684f4f989d45bef541c4e2cd3a2619a3b7 (diff) | |
download | couchdb-67fd6f3a6e2d4b55b547de7e0fc822939fb0d48f.tar.gz |
Make timeout for check-over-RPC configurable
This commit adds a --timeout option (short name -t) which specifies
the timeout value used when running each diagnostic check via RPC
(i.e. using the -a option).
The default timeout is also changed from 5s to 5m.
BugzID: 33697
-rw-r--r-- | src/weatherreport/src/weatherreport.erl | 6 | ||||
-rw-r--r-- | src/weatherreport/src/weatherreport_config.erl | 11 | ||||
-rw-r--r-- | src/weatherreport/src/weatherreport_node.erl | 2 | ||||
-rw-r--r-- | src/weatherreport/src/weatherreport_runner.erl | 2 |
4 files changed, 18 insertions, 3 deletions
diff --git a/src/weatherreport/src/weatherreport.erl b/src/weatherreport/src/weatherreport.erl index 02258a6fe..67283178b 100644 --- a/src/weatherreport/src/weatherreport.erl +++ b/src/weatherreport/src/weatherreport.erl @@ -61,7 +61,8 @@ {expert, $e, "expert", undefined, "Perform more detailed diagnostics" }, {usage, $h, "help", undefined, "Display help/usage" }, {list, $l, "list", undefined, "Describe available diagnostic tasks" }, - {all_nodes, $a, "all-nodes", undefined, "Run weatherreport on all cluster nodes" } + {all_nodes, $a, "all-nodes", undefined, "Run weatherreport on all cluster nodes" }, + {timeout, $t, "timeout", integer, "Timeout value (in ms) for each diagnostic check" } ]). -define(USAGE_OPTS, [ O || O <- ?OPTS, @@ -162,6 +163,9 @@ process_option({etc,Path}, Result) -> process_option({level, Level}, Result) -> application:set_env(weatherreport, log_level, Level), Result; +process_option({timeout, Timeout}, Result) -> + application:set_env(weatherreport, timeout, Timeout), + Result; process_option(expert, Result) -> application:set_env(weatherreport, expert, true), Result; diff --git a/src/weatherreport/src/weatherreport_config.erl b/src/weatherreport/src/weatherreport_config.erl index e93da8359..cee6c9a75 100644 --- a/src/weatherreport/src/weatherreport_config.erl +++ b/src/weatherreport/src/weatherreport_config.erl @@ -39,6 +39,7 @@ data_directories/0, get_vm_env/1, etc_dir/0, + timeout/0, node_name/0, cookie/0, user/0]). @@ -87,6 +88,16 @@ user() -> lists:reverse(Resp1) end. +%% @doc The specified timeout value for diagnostic checks run via RPC +-spec timeout() -> integer(). +timeout() -> + case application:get_env(weatherreport, timeout) of + {ok, Timeout} -> + Timeout; + _ -> + 300000 + end. + %% @doc The CouchDB configuration directory. -spec etc_dir() -> file:filename(). etc_dir() -> diff --git a/src/weatherreport/src/weatherreport_node.erl b/src/weatherreport/src/weatherreport_node.erl index 1df6cc849..6d366b783 100644 --- a/src/weatherreport/src/weatherreport_node.erl +++ b/src/weatherreport/src/weatherreport_node.erl @@ -55,7 +55,7 @@ local_command(Module, Function) -> %% @see can_connect/0 -spec local_command(Module::atom(), Function::atom(), Args::[term()]) -> term(). local_command(Module, Function, Args) -> - local_command(Module, Function, Args, 5000). + local_command(Module, Function, Args, weatherreport_config:timeout()). %% @doc Calls the given module and function with the given arguments %% on the local node and returns the result of that call, diff --git a/src/weatherreport/src/weatherreport_runner.erl b/src/weatherreport/src/weatherreport_runner.erl index 95da6911e..d2dafa6a3 100644 --- a/src/weatherreport/src/weatherreport_runner.erl +++ b/src/weatherreport/src/weatherreport_runner.erl @@ -57,7 +57,7 @@ run(Checks, Nodes) -> erlang, apply, [fun() -> {node(), weatherreport_check:check(Mod, CheckOpts)} end, []], - 5000 + weatherreport_config:timeout() ), lists:map(fun(Node) -> weatherreport_util:log( |