From 31ab973b30eedeae652d0790bbe1daddc9122a52 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Thu, 8 Jun 2023 17:54:43 +0200 Subject: [PATCH] refactor(emqx_conf_cli): rename cluster_call ctl command Renamed 'clustedr_call' ctl command to 'cluster_sync' as a sub-command of 'conf' The old 'cluster_call' command is kept, but no usage prints --- apps/emqx_conf/src/emqx_conf_cli.erl | 51 +++++++++++++++++----------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/apps/emqx_conf/src/emqx_conf_cli.erl b/apps/emqx_conf/src/emqx_conf_cli.erl index 9240d2116..c0ca18100 100644 --- a/apps/emqx_conf/src/emqx_conf_cli.erl +++ b/apps/emqx_conf/src/emqx_conf_cli.erl @@ -22,11 +22,12 @@ unload/0 ]). +%% kept cluster_call for compatibility -define(CLUSTER_CALL, cluster_call). -define(CONF, conf). load() -> - emqx_ctl:register_command(?CLUSTER_CALL, {?MODULE, admins}, []), + emqx_ctl:register_command(?CLUSTER_CALL, {?MODULE, admins}, [hidden]), emqx_ctl:register_command(?CONF, {?MODULE, conf}, []). unload() -> @@ -41,17 +42,10 @@ conf(["show", Key]) -> print_hocon(get_config(Key)); conf(["load", Path]) -> load_config(Path); +conf(["cluster_sync" | Args]) -> + admins(Args); conf(_) -> - emqx_ctl:usage( - [ - %% TODO add reload - %{"conf reload", "reload etc/emqx.conf on local node"}, - {"conf show --keys-only", "print all keys"}, - {"conf show", "print all running configures"}, - {"conf show ", "print a specific configuration"}, - {"conf load ", "load a hocon file to all nodes"} - ] - ). + emqx_ctl:usage(usage_conf() ++ usage_sync()). admins(["status"]) -> status(); @@ -87,14 +81,33 @@ admins(["fast_forward", Node0, ToTnxId]) -> emqx_cluster_rpc:fast_forward_to_commit(Node, TnxId), status(); admins(_) -> - emqx_ctl:usage( - [ - {"cluster_call status", "status"}, - {"cluster_call skip [node]", "increase one commit on specific node"}, - {"cluster_call tnxid ", "get detailed about TnxId"}, - {"cluster_call fast_forward [node] [tnx_id]", "fast forwards to tnx_id"} - ] - ). + emqx_ctl:usage(usage_sync()). + +usage_conf() -> + [ + %% TODO add reload + %{"conf reload", "reload etc/emqx.conf on local node"}, + {"conf show --keys-only", "Print all config keys"}, + {"conf show", "Print config in use"}, + {"conf show ", "Print configs under the given key"}, + {"conf load ", + "Load a HOCON format config file." + "The config is overlay on top of the existing configs. " + "The current node will initiate a cluster wide config change " + "transaction to sync the changes to other nodes in the cluster. " + "NOTE: do not make runtime config changes during rolling upgrade."} + ]. + +usage_sync() -> + [ + {"conf cluster_sync tatus", "Show cluster config sync status summary"}, + {"conf cluster_sync skip [node]", "Increase one commit on specific node"}, + {"conf cluster_sync tnxid ", + "Display detailed information of the config change transaction at TnxId"}, + {"conf cluster_sync fast_forward [node] [tnx_id]", + "Fast-forward config change transaction to tnx_id on the given node." + "WARNING: This results in inconsistent configs among the clustered nodes."} + ]. status() -> emqx_ctl:print("-----------------------------------------------\n"),